Are you using Axis for web services and wondering why your WSDL describes services whose parameter names appear to be auto-generated, i.e. ‘in0′,’in1′,’in2′? This post is for you!
Say you want to use the Axis utility Java2WSDL to generate a WSDL from your Java class. Assume you have a file called Test.java like this -
public class Test {
public void test(String testParam) {
}
}
Java2WSDL, via ant task or command-line, would ideally generate a WSDL with an operation called ‘test’ and a parameter to the ‘testRequest’ called ‘testParam’.
<wsdl:message name="testRequest">
<wsdl:part name="testParam" type="soapenc:string"/>
</wsdl:message>
However, if you compiled Test.java without the -g option (debug) and run Java2WSDL on the resulting class file, you’ll end up with ‘testRequest’ having a a parameter named ‘in0′.
<wsdl:message name="testRequest">
<wsdl:part name="in0" type="soapenc:string"/>
</wsdl:message>
Because Java2WSDL relies on the compiled class file and not the source file, the class file needs to be compiled with the debug option so it can provide method parameter names. In fact, if you compile Test.java without debug and open it in eclipse, you’ll see that the ’source’ shows a method declaration like this
public void test(String arg0)
Compile it with debug turned on and the method declaration looks like this
public void test(String testParam)
This information is covered by one line in the Axis user’s guide -
Note: If you compile your class with debug information, Java2WSDL will use the debug information to obtain the method parameter names.
Side Note
As a practice, we define a set of services in an interface class and then provide a concrete implementation class. As I was doing testing for this article, I found that *no debug* information is provided when you compile an interface, even if you specify all of the debug flags to javac.
Bottom line – if you want the parameter names for your methods to appear in your WSDL, make sure you reference actual classes and not interfaces when using Java2WSDL.
Posted by mcoopet 