Using .NET v2.0 generated WSDLs with JAX-WS: How to resolve “A class/interface with the same name “XXXX” is already in use. Use a class customization to resolve this conflict”?


I’ve noticed an issue in WSDLs generated by .NET 2.0 apps: some of the element(s) and their corresponding complextype definitions have same name. If you happen to generate JAX-WS portable artifacts (see below) from one such WSDL for your project (during technology migration etc. and you don’t want the consumers who use this WSDL to be affected) using conversion tools like Apache CXF (wsdl2java ), Apache Axis (WSDL2Java), JAX-WS (wsimport) etc., you’ll most likely get this error:

A class/interface with the same name “XXXX” is already in use. Use a class customization to resolve this conflict. 

Resolution

1) Apache CXF (wsdl2java tool or cxf-codegen-plugin Maven plugin)

Use an option/argument -autoNameResolution that automatically resolves naming conflicts in WSDL without requiring the use of binding customizations.

2) wsimport (a JAX-WS tool)

Use an option -B-XautoNameResolution (without spaces)

3) Apache Axis (WSDL2Java tool) or eBay Turmeric SOA Framework

It’s a bit tricky here, the WSDL needs to be modified a little bit.

We can seperate out element(s) and the corresponding complextype definitions in different namespaces. This way the two Java classes with same name (one for element, another for complex type) will get generated in different packages and hence there wouldn’t be any problem in generating service code. There can be other tweaks too which would serve the same purpose, but I think the aforementioned one is cleaner, as we need not have to change the names of element/complex type definition.


JAX-WS portable artifacts

  • Service Endpoint Interface (SEI)
  • Service
  • Exception class mapped from wsdl:fault (if any)
  • Async Reponse Bean derived from response wsdl:message (if any)
  • JAXB generated value types (mapped java classes from schema types)
About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 26 other followers

%d bloggers like this: