wsdl2java工具:
Usage : wsdl2java -fe|-frontend <front-end-name> -db|-databinding <data-binding-name>
-wv <wsdl-version> -p <[wsdl-namespace =]package-name>* -sn <service-name>
-b <binding-file-name>* -reserveClass <class-name>* -catalog <catalog-file-name>
-d <output-directory> -compile -classdir <compile-classes-directory> -impl -server
-client -clientjar <jar-file-name> -all -autoNameResolution -allowElementReferences|-aer<=true>
-defaultValues<=class-name-for-DefaultValueProvider> -ant
-nexclude <schema-namespace [= java-package-name]>* -exsh <(true, false)> -noTypes
-dns <(true, false> -dex <(true, false)> -validate -keep
-wsdlLocation <wsdlLocation> -xjc<xjc-arguments>* -asyncMethods<[=method1,method2,...]>*
-bareMethods<[=method1,method2,...]>* -mimeMethods<[=method1,method2,...]>* -noAddressBinding
-faultSerialVersionUID <fault-serialVersionUID> -exceptionSuper <exceptionSuper>
-mark-generated -h|-?|-help -version|-v -verbose|-V -quiet|-q|-Q -wsdlList <wsdlurl>
使用多个-p选项,把不同的wsdl-namespace生成到不同的package中
默认生成的日期类型是XMLGregorianCalendar
可以通过-b参数改成java.util.Date
[注意]:<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://tempuri.org/Imports']">
中的targetNamespace根据需要更换。
<?xml version="1.0"?> <project name="cxf wsdl2java" basedir="." default="cxfWSDLToJava"> <property name="cxf.home" location="E:\tools\apache-cxf-2.7.4" /> <path id="cxf.classpath"> <fileset dir="${cxf.home}/lib"> <include name="*.jar" /> </fileset> </path> <target name="cxfWSDLToJava"> <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true"> <arg value="-client" /> <arg value="-p" /> <arg value="http://www.w3.org/2001/XMLSchema=com.test.adapter"/> <arg value="-p" /> <arg value="http://schemas.microsoft.com/2003/10/Serialization/=com.test.serialization"/> <arg value="-p" /> <arg value="http://schemas.microsoft.com/2003/10/Serialization/Arrays=com.test.serialization.arrays"/> <arg value="-p" /> <arg value="http://tempuri.org/=com.test"/> <arg value="-b" /> <arg value="hotelapi-binding-date.xml"/> <arg value="-d" /> <arg value="../test/java" /> <arg value="http://xxx.com/SouthBoundService.svc?wsdl"/> <classpath> <path refid="cxf.classpath" /> </classpath> </java> </target> </project>
<?xml version="1.0" encoding="UTF-8"?> <jaxws:bindings wsdlLocation="http://supplier.elong.com/HOTELAPI/V1.0/SouthBoundService.svc?wsdl" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> <jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://tempuri.org/Imports']"> <jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <jxb:javaType name="java.util.Date" xmlType="xs:dateTime" parseMethod="org.apache.cxf.tools.common.DataTypeAdapter.parseDateTime" printMethod="org.apache.cxf.tools.common.DataTypeAdapter.printDateTime" /> </jxb:globalBindings> </jaxws:bindings> </jaxws:bindings>