2

I am trying to force WSDL2Java (org.apache.axis2.wsdl.WSDL2Java) to generate all the classes under a given base package, for example com.mycompany.thewebservice.*

According to the documentation the -p option should do the trick:

-p --package The target package name. If omitted, a default package (formed using the target namespace of the WSDL) will be used.

But unfortunately when we use the -p option, only the 3 main classes (XService.java, XCallbackHandler.java and XServiceStub.java) are generated under the given package. Many other packages are generated like for example:

  • com.theservice.*
  • org.w3.www._2004._60.xmlmime
  • org.xmlsoap.schemas.soap.encoding

This is a mess for us because we integrate many webservices and we want to keep all the classes for a service under a common base folder.

We were using Axis 1 in the past and its WSDL2Java (org.apache.axis.wsdl.WSDL2Java) has a parameter --package that works like a charm. In this case all the classes are neatly generated under the package that I specify.

Is there a way to force Axis 2 WSDL2Java to generate all the classes under a given package? I know about the -ns2p --namespace2package parameter, but I don't want to list the URLs one by one for every service that we integrate.

Óscar
  • 650
  • 1
  • 4
  • 16
  • Reported as an Axis 2 WSDL2Java bug: https://issues.apache.org/jira/projects/AXIS2/issues/AXIS2-5940 – Óscar Nov 14 '18 at 09:15

1 Answers1

0

I'm using axis2-eclipse-codegen-plugin-1.7.9 and -p option also doesn't place all the generated classes under one package for me.

I have found a workaround for that issue.

1) Simply drop downloaded axis2-eclipse-codegen-plugin-1.7.9.jar file under Eclipse/STS folder named "droppings"
2) restart your Eclipse-based IDE
3) from STS menu go to File --> New --> Other... , select Axis2 Code Generator (under Axis2 Wizards) --> click on Next --> select "Generate Java source code from a WSDl file" --> Next --> point to your WSDL file location --> Next --> for Codegen option select custom, fill the other fields --> click on the Advance Options and there
4) uncheck the checkbox "Unpacks the databinding classes" like on the screen shot below, it tells Axis2 to generate all the binding classes as inner classes according to Axis2 CodegenToolReference :

unpackClasses Unpacks the generated classes. This forces the databinding classes to be generated separately, which otherwise would have been generated as inner classes.

Axis2 Codegen Wizard

kels
  • 138
  • 2
  • 11