Generating client code - bahkified/Notes GitHub Wiki
Apache CXF wsdl2java
The command line tool can be run from Gradle
Or run on the command line:
wsdl2java -fe jaxws21 -d ~/Laureate/torrens-payment-gateway/src/main/java/ -p net.laureate.sis.esb \
~/Laureate/torrens-payment-gateway/src/main/resources/StudentInfoService.wsdl
- -fe jaxws21 generate client code that is compliant with JAX-WS 2.1
- -d <arg> output directory of java code
- -p <arg> target package name
If information needs to go into the SOAP header, the following flag might need to be used:
- -exsh true enables the processing of implicit SOAP headers. You may need to add a dependency to cxf-rt-binding-soap for this flag to work.
Apache Axis2 wsdl2java
Command line tool, similar to Apache CXF for generating SOAP based web service client. To use it, run the command as below (without the linebreaks):
~/Downloads/axis2-1.6.2/bin/wsdl2java.sh -uri ~/Laureate/torrens-payment- \
gateway/src/main/resources/CyberSourceTransaction_1.96.wsdl -S ~/Laureate/torrens-payment- \
gateway/src/main/java/ -R ~/Laureate/torrens-payment-gateway/src/main/resources -p \
com.cybersource.transaction -u
- Identify where the script is located.
- Several flags are used:
- -S <path> : specifies the source directory in which to place the generated code.
- -R <path> : specifies the resource directory in which to place the generated resources.
- -uri <path> : specifies the location on the local file system of the WSDL file to be used.
- -u : tells the tool to unpack the generated classes. Without this flag, all of the data classes will be included as inner classes in the generated stub class, resulting in a very large class (the one for the payment transaction service was over 250k lines).
- -p <arg> : specifies the package in which to place the generated classes. Overrides the target namespace specified in the WSDL.
Resources
- CXF wsdl2java reference: http://cxf.apache.org/docs/wsdl-to-java.html
- Axis2 wsdl2java reference: http://axis.apache.org/axis2/java/core/docs/reference.html