1. Download the apache-cxf-2.7.5.zip file and unzip it
Execute wsdl2java -encoding UTF-8 -all xxx.wsdl in the bin directory. After the code is generated, copy it to eclipse and find an error:
The constructor Service(URL, QName, WebServiceFeature[]) is undefined
Refer to http://blog.csdn.net/luckarecs/article/details/7233369 to know that the reason is that the version of javax.xml.service that comes with CXF is higher than the javax.xml.service of jdk. The solution is to add -frontend jaxws21
So modified to wsdl2java -encoding UTF-8 -all -frontend jaxws21 xxx.wsdl
2 Detailed parameter description:
wsdl2java usage:
wsdl2java -p com -d src -all aa.wsdl
-p specifies the namespace of its wsdl, that is, the package name of the code to be generated:
-d specifies the directory where the code is to be generated
-client generates the client-side test web service Code -server generates the code for the
server to start the web service-
impl generates the implementation code of the web service-
ant generates the build.xml file
-all generates all the starting endpoint codes: types, service proxy,, service interface, server mainline, client mainline, implementation object , and an Ant build.xml file.
3. When the soapui tool calls the Webservice, it keeps reporting an error
javax.xml.bind.UnmarshalException: unexpected element (uri: "", local: "arg0"), I finally found it online and found out
I have added the @WebParam(name="sampleId") annotation to the formal parameters of the method, but the request editor generated by the soapui tool is still arg0. After changing it to sampleId, everything is OK