Tag Archives: JAX-WS

JAX-WS: Working with .NET Web Services

If you happen to write a JAX-WS Web Services client for a service which is written using .NET Platform, you might come across the below error message when you execute wsimport command.

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

This happens because .NET generated WSDL documents may contain multiple elements with same name, which leads to a naming conflict when JAXB attempts to generate bindings. If you ever come across this situation, the solution is very simple. You just have to instruct the JAXB generator to automatically resolve any naming conflicts that might occur during the code generation. This can be done by providing -B-XautoNameResolution argument to wsimport tool. Note that the ‘-B-XautoNameResolution’ has no spaces. -B is used to pass instructions to JAXB Schema Compiler.

An example would be:

wsimport -d gen-src -verbose -B-XautoNameResolution  https://sample.net/service.asmx?WSDL

Note that generated code will refer to duplicate names with a numeric suffix. For example, if there are two elements with name ‘XYZ’, one class will be ‘XYZ’, and the other occurrence will be named as ‘XYZ2’.

Changing the default JBossWS (JAX-WS) Web Service End Point Address

If you are working with JAX-WS on JBoss (in my case version 4.2.3.GA) to expose SLSBs as Web Services, you might notice that in the generated WSDL, the end-point address is set as the machine’s name or localhost. The address JBoss uses by default is the ‘bind address’, which you can specify via the -b argument when starting up the container. If you (like me) are specifying it as 0.0.0.0 (which binds it for all interfaces), it generally resolves to the machine name.

This affects a lot if the JBoss instance is published to the web, since we would like to have the WSDL end point mappings via the public IP address. I had this problem for quite a time, and finally managed to find the solution for this in the JBoss Forums. With a slight change in the JBoss configuration, you can get JBoss to use any IP address of your choice in the WSDL.

The steps are as follows:

  1. Goto deploy/jbossws.sar/jbossws.beans/META-INF
  2. Edit the jboss-beans.xml file (the file itself is well commented)
  3. Change the webServiceHost property to the address that you wish to have.