10

I'm generating a WSDL from a Java class using the @WebService annotation and running wsgen, triggered by a Maven build target.

The problem I have is the generated WSDL defines the parameters for the web service operations as arg0, ar1, arg2, etc instead of using the parameter names from the code. These names are not helpful to clients of the service attempting to figure out what needs to be passed in.

Is there a way to tell wsgen to grab and use the parameter names from the method - either by placing an annotation on the method or a parameter sent to wsgen?

Thanks!

Vinnie
  • 12,400
  • 15
  • 59
  • 80

1 Answers1

15

Use the @WebParam annotation.

@WebMethod
public void thisMethodHasAWebParam(@WebParam(name="param1") String arg1) {
}
Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • I knew there had to be an easy way to do this. Thanks so much! – Vinnie Jan 26 '10 at 16:42
  • 3
    That works. But isn't this horribly redundant? I know that method signatures in byte code do not preserve the parameter names, but cannot the tool also look at the source code? – Thilo Jan 18 '11 at 08:05
  • 1
    How it can look into source code, as it uses WSDL file URL when generating code. And WSDL file is generated at runtime. – Asif Shahzad Apr 03 '12 at 12:20