According to the WSDL interface, the Wsdljava client code is generated via Apache CXF, and the problem record in the process occurs

Source: Internet
Author: User
Tags wsdl
First of all, there are two ways to generate WSDL client code:
1. Wsdl2java Generation via Apache CXF
1. First download the apace CXF package, configure the environment variables, and the Java environment variables to configure the same way.
Configure the Cxf_home value to D:\cxf\apache-cxf-3.0.0 in the environment variable and add%cxf_home%\bin in Path
Verify that the environment variable has not been configured successfully, CMD window, input Wsdl2java
2). Wsdl2java Usage:
Wsdl2java-p com-d Src-all WSDL


-p Specifies the namespace of its WSDL, which is the name of the package to generate code for
-d Specifies the directory where the code is to be generated
-client code to generate client test Web service
-server the code for the build server to start the Web service
-impl to generate Web service implementation code
-ant Generate Build.xml files
-all generates all start endpoint codes: Types,service Proxy,,service interface, server mainline, client mainline, implementation object, and an T build.xml file.


The build directory specified by the instance is the D disk below src directory: wsdl2java-p com-d d:/src-client http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl
with new questions:

Today encountered a problem, the generated entity class in the string attribute, more than one parameter type protected jaxbelement<string> address, resulting in a problem calling the property.
After the search, you need to control the generated files at the time of the build, step:
1. First create 1.txt text content locally (I am in the C-packing directory), the placement of the position does not seem to matter. Text into the
<jaxb:bindings version= "2.1"
xmlns:jaxb= "HTTP://JAVA.SUN.COM/XML/NS/JAXB"
Xmlns:xjc= "HTTP://JAVA.SUN.COM/XML/NS/JAXB/XJC"
xmlns:xs= "Http://www.w3.org/2001/XMLSchema" >
<jaxb:globalbindings generateelementproperty= "false"/>
</jaxb:bindings>
2. Execute command in CMD
Wsdl2java-p com.wang.provider.syncresult-d d:/src-b "1.txt"-client http://www.webxml.com.cn/webservices/qqOnlineWe bservice.asmx?wsdl

Generally explained:-P is followed by the package name of the code to be generated, and-D refers to the directory where the code is generated, the name of the-B-bound file under D-SRC,

One months later encountered a new problem, when used again, I first cmd input wsdl2java-v Verify that the error is Java.lang.illegalargumentexception:uri are not hierarchical do not understand 。 The environment variable was configured before, and then in the environment variable I chose the CXF path again.


2. Generating WSDL client code through the SOAPUI tool



Problem:
1.Running Apache CXF Wsdl2java for [soapeventsourcebinding]
Directory:c:\program Files\apache-cxf-3.1.10\bin
Command: [cmd.exe,/C, Wsdl2java.bat, D, D:\WSDL,-exsh, False,-dns, True,-dex, True,-verbose, C:\Users\Admin\AppData\ LOCAL\TEMP\TEMPDIR17737533249299.TMP\XXXXXXXXXXXXXXXXXXXXIMPLSERVICE_1.WSDL]
The file name, directory name, or volume banner method is incorrect.
This problem occurs because the Java_home has two values and is configured with two JDK
2.
Running Apache CXF Wsdl2java
Directory:c:\program Files\apache-cxf-3.1.10\bin
Command: [cmd.exe,/C, Wsdl2java.bat, D, D:\wsdl,-client,-exsh, False,-dns, True,-dex, True,-verbose, Http://www.web Xml.com.cn/webservices/qqonlinewebservice.asmx]
java.lang.unsupportedclassversionerror:org/apache/cxf/tools/wsdlto/wsdltojava:unsupported Major.minor Version 51.0
At Java.lang.ClassLoader.defineClass1 (Native method)
At Java.lang.ClassLoader.defineClassCond (classloader.java:631)
At Java.lang.ClassLoader.defineClass (classloader.java:615)
At Java.security.SecureClassLoader.defineClass (secureclassloader.java:141)
At Java.net.URLClassLoader.defineClass (urlclassloader.java:283)
At java.net.urlclassloader.access$000 (urlclassloader.java:58)
At Java.net.urlclassloader$1.run (urlclassloader.java:197)
At Java.security.AccessController.doPrivileged (Native method)
At Java.net.URLClassLoader.findClass (urlclassloader.java:190)
At Java.lang.ClassLoader.loadClass (classloader.java:306)
At Sun.misc.launcher$appclassloader.loadclass (launcher.java:301)
At Java.lang.ClassLoader.loadClass (classloader.java:247)
Could not find the main Class:org.apache.cxf.tools.wsdlto.WSDLToJava. Program would exit.
Exception in thread "main"

The official web is written in this way Apache CXF version 3.1 does not support jdk1.6, needs to jdk1.7 above, contains 1.7 version: The "is" that CXF 3.1 will no longer support Java 6 And would require Java 7 or newer. Users are strongly encouraged to start moving to Java 7.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.