通过 -b 参数可以指定多个 JAX-WS 和 JAXB 的绑定文件 ,这可以用来定制各种选项: 包名, 类名, 等.
更多的使用细节可以查看:http://jax-ws.java.net/nonav/2.2.7/docs/ch04.html#tools-wsimport
Option | Description |
---|---|
-d <directory> | 指定输出目录 |
-b <path> | 指定JAXWS或者JAXB的绑定文件,可以多个 |
-B <jaxbOption> | 指定JAXB的参数,透传给JAXB命令 |
-catalog | 绑定外部WSDL或XSD,解决外部WSDL或者XSD引用 |
-extension | Allow vendor extensions (functionality not specified by the specification). Use of extensions may result in applications that are not portable or may not interoperate with other implementations. |
-help | 显示帮助 |
-httpproxy:<host>:<port> | 指定一个HTTP代理 |
-keep | 保留源文件 |
-p <pkg> | 指定包名 |
-s <directory> | 指定源代码存放目录 |
-encoding <encoding> | 指定编码格式,例如UTF-8 |
-verbose | 指定输出命令执行的详细信息 |
-version | 显示版本 |
-fullversion | 显示详细的版本信息 |
-clientjar <jarfile> | Creates the jar file of the generated artifacts along with the WSDL metadata required for invoking the web service. |
-wsdllocation <location> | @WebServiceClient.wsdlLocation value. |
-target <version> | 指定JAX-WS的版本,默认是 2.2. |
-quiet | 静默执行该命令,不在屏幕输出信息 |
-XadditionalHeaders | Map the headers not bound to request or response message to Java method parameters. |
-Xauthfile | File to carry authorization information in the format http://username:password@example.org/stock?wsdl . Default value is $HOME/.metro/auth |
-Xdebug | 显示DEBUG信息 |
-XdisableAuthenticator | Disables Authenticator used by JAX-WS RI, -Xauthfile option will be ignored if -XdisableAuthenticator is set. |
-Xno-addressing-databinding | 不使用JDK的Addressing,生成自己的EndpointReferenceType |
-Xnocompile | 不编译生成的源码 |
-XdisableSSLHostnameVerification | Disbales the SSL Hostname verification while fetching the wsdls. |
wsimport不区分cient端和server端,发布出来就是一套代码
【举例】
wsimport -b jaxws_binding.xml -catalog jaxws_catalog.xml -Xno-addressing-databinding -extension -keep -d server\bin -s server\src example.wsdl
【说明】
Ø 如果需要指定引用本地wsdl或者xsd文件,需要加上-catalog参数:
wsimport –catalog catalogfile.xml -keep -d bin -s src wsdl/HelloService.wsdl
Ø 如果需要加入数据绑定,加上 –b参数:
wsimport –b bindingfile.xml –catalog catalogfile.xml -keep -d bin -s src wsdl/HelloService.wsdl
Ø 如果需要避免发布的时候还需要去找 http://www.w3.org/2005/08/addressing/ws-addr.xsd 及相关的xsd,加上参数-Xno-addressing-databinding –extension
其中:如果不指定 -Xno-addressing-databinding参数,将使用JDK自带的 addressing,
wsimport –b bindingfile.xml –catalog catalogfile.xml -Xno-addressing-databinding –extension -keep -d bin -s src wsdl/HelloService.wsdl
Ø -b 绑定文件的配置例子:
<jaxws:bindings wsdlLocation="JVTTroubleTicketSession.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">
<jxb:globalBindings
fixedAttributeAsConstantProperty="true" typesafeEnumBase="xs:string"
choiceContentProperty="false" typesafeEnumMaxMembers="50"
enableFailFastCheck="false" generateIsSetMethod="false"
underscoreBinding="asCharInWord" generateElementProperty="false">
<jxb:javaType name="java.util.Calendar" xmlType="xs:dateTime"
parseMethod="javax.xml.bind.DatatypeConverter.parseDate"
printMethod="javax.xml.bind.DatatypeConverter.printDate"/>
</jxb:globalBindings>
</jaxws:bindings>
</jaxws:bindings>