Cxf -wsdl2java 使用参数介绍

摘要:
Wsdl2java-h可以获得详细的参考文档:G:cxfapapache-xf-3.16in˃Wsdl2java-hwsdl2java.fe|-fronend-db|-databinding-wv-p*-sn-

wsdl2java -h 可以得到详细的参考文档:

G:cxfapache-cxf-3.1.6in>wsdl2java -h
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 <Default value is true> 
-dex <(true, false)> -validate<[=all|basic|none]> -keep 
-wsdlLocation <wsdlLocation> -xjc<xjc-arguments>* -asyncMethods<[=method1,method2,...]>* 
-bareMethods<[=method1,method2,...]>* -mimeMethods<[=method1,method2,...]>* -noAddressBinding 
-faultSerialVersionUID <fault-serialVersionUID> -encoding <encoding> -exceptionSuper <exceptionSuper> 
-seiSuper <seiSuper>* -mark-generated -h|-?|-help -version|-v -verbose|-V -quiet|-q|-Q -wsdlList <wsdlurl>

Options:

   -fe|-frontend <front-end-name>
                     Specifies the front end. (defaults to JAXWS)

   -db|-databinding <data-binding-name>
                     Specifies the data binding. (defaults to JAXB)

   -wv <wsdl-version>
                     Specifies the WSDL version. (default is WSDL1.1)

   -p <[wsdl-namespace =]package-name>*
                     Specifies the java package name to use for the generated
                     code. Optionally specify a WSDL namespace to Java package
                     name mapping.

   -sn <service-name>
                     Specify he WSDL service name to use for the generated code.
                     Also, optionally specify the WSDL namespace.

   -b <binding-file-name>*
                     Specify an external jaxws or jaxb binding files. Use one -b
                     flag for each binding file.

   -reserveClass <class-name>*
                     Reserve a class name to keep the code generator from
                     generating a class of the given name. In name cases, a
                     binding file or use of -autoNameResolution flag may be
                     necessary for the code generator to completely generate
                     usable code.

   -catalog <catalog-file-name>
                     Specify catalog file to map the imported wsdl/schema.

   -d <output-directory>
                     Specify the directory into which the code is placed.

   -compile          Specifies that the generated code is compiled by the tool.

   -classdir <compile-classes-directory>
                     Specifies the directory into which compiled class files are
                     placed.

   -impl             Specifies that a dummy service implementation is generated.

   -server           Specifies that server code is generated.

   -client           Specifies that client code is generated.

   -clientjar <jar-file-name>
                     Package all the client classes and wsdl in a jar file

   -all              Specifies that interfaces, types , service, server , dummy
                     impl, client and ant script are generated.

   -autoNameResolution
                     Specifies that the tool will attempt to resolve class
                     naming conflicts without requiring the use of binding
                     customizations.

   -allowElementReferences|-aer<=true>
                     allowElementReferences

   -defaultValues<=class-name-for-DefaultValueProvider>
                     Specifies that default values are generated for the dummy
                     implementation and client. You can specify the name of the
                     class to provide the default values. The default is
                     RandomValueProvider.

   -ant              Specifies that an ant build script is generated for the
                     project.

   -nexclude <schema-namespace [= java-package-name]>*
                     Specifies a WSDL namespace to exclude when generating code.
                     This option can be specified multiple times. Optionally
                     specify the Java package name to use for the WSDL
                     namespace.

   -exsh <(true, false)>
                     Enables the processing of extended SOAP header message
                     binding.

   -noTypes          Turns off generating types

   -dns <Default value is true>
                     Enables loading the default namespace package name mapping.
                     The default is true.

   -dex <(true, false)>
                     Enable loading the default excludes namespace mapping. The
                     default is true.

   -validate<[=all|basic|none]>
                     Specifies that the WSDL is validated before generating the
                     code. Using this option is highly recommended. By default,
                     only very basic validation is done to make sure the WSDL
                     meets the WSI-BasicProfile standards that CXF requires.
                     -validate=none can turn off those checks while -validate or
                     -validate=all turns on additional schema validation and
                     other checks.

   -keep             Specifies that existing code will not be over written.
                     NOTE: You will have to solve any resulting compilation
                     problems by yourself

   -wsdlLocation <wsdlLocation>
                     Specifies the value of the @WebServiceClient annotation's
                     wsdlLocation property.

   -xjc<xjc-arguments>*
                     Specifies a comma separated list of arguments that are
                     passed directly to XJC when the JAXB data binding is used.
                     This option causes XJC to load additional plugins that
                     augment code generation. For example to load the
                     toString(ts) plugin that will add a toString() method to
                     all generated types the following <xjc arguments> would be
                     used: -xjc-Xts A list of available XJC plugins can be
                     obtained by using -xjc-X.

   -asyncMethods<[=method1,method2,...]>*
                     Specifies a comma separated list of methods that should
                     have asynchronous version generated in addition to the
                     normal synchronous versions. If no methods are listed, all
                     methods are generated with asynchronous versions.

   -bareMethods<[=method1,method2,...]>*
                     Specifies a comma separated list of methods that should not
                     be unwrapped into individual parameters and instead be left
                     in their "bare" form.

   -mimeMethods<[=method1,method2,...]>*
                     Specifies a comma separated list of methods where the
                     mime:content information is used to generate the type.

   -noAddressBinding Specifies that the generator should not use the address
                     jaxb binding file to map wsa:EndpointReferenceType or
                     wsa:EndpointReference to
                     javax.xml.ws.wsaddressing.W3CEndpointReference.

   -faultSerialVersionUID <fault-serialVersionUID>
                     Specifies how to generate fault Exception's SUID, can use
                     NONE|TIMESTAMP|FQCN|####", the default is NONE. FQCN uses a
                     hash of the fully qualified class name. #### would be any
                     valid Long to use as the SUID.

   -encoding <encoding>
                     Specifies the charset encoding to use when generating java
                     sources

   -exceptionSuper <exceptionSuper>
                     Specifies the superclass to use for generated exceptions,
                     the default is java.lang.Exception.

   -seiSuper <seiSuper>*
                     Specifies the SuperInterface to use for generated Service
                     Interfaces.

   -mark-generated   Adds @Generated annotation in all java files that are
                     generated.

   -h|-?|-help       Display detailed information for options.

   -version|-v       Display the version of the tool.

   -verbose|-V       Specifies that the generator runs in verbose mode.

   -quiet|-q|-Q      Specifies that the generator runs in quiet mode.

   -wsdlList         Indicates the wsdlurl is a plain text list of wsdlurls that
                     are new line delimited. As an example the wsdlurl might
                     point to
                     http://127.0.0.1:8080/context_path/ws?formatted=false&wsdlL
                     ist=true on a cxf server.

   <wsdlurl>         wsdl-url

说一下其中比较重要的几个:

-p 指定生产的代码的包路径,也就是生成的代码,我们将要放在哪个包下面;
-d 指定生产的代码的位置,也就是生成的代码放在哪个磁盘哪个目录下面;
演示:
G:cxfapache-cxf-3.1.6in>wsdl2java -p com.hemr.hl7.ws.client -d G: ew_wsEMRsrc -verbose http://localhost:8080/webservice/hL7MessageReveiver?wsdl
Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -p com.hemr.hl7.ws.client -d G: ew_wsEMRsrc -verbose http://localhost:8080/webservice/hL7MessageReveiver?wsdl
wsdl2java - Apache CXF 3.1.6
 
上面的命令表示,将生成的代码放入到项目 G: ew_wsEMRsrc 源码目录,下的包路径:com.hemr.hl7.ws.client 下面去。
 
除了 -p 指定生成的代码包名(命名空间),-d 指定代码生成的位置,还有几个比较重要的选项:
 
1> -client 会帮我们生成调用服务的客户端代码:
wsdl2java -client -p com.hemr.hl7.ws.client -d D:from_oldworkspaceWebServiceTestsrc -verbose http://localhost:8080/webservice/hL7MessageReveiver?wsdl
生成的代码稍微修改一下调用参数,就可以使用了。
 
2> -server -impl会帮我们生成web service发布和服务端的实现代码(空实现):
wsdl2java -server -impl -p com.hemr.hl7.ws.server -d D:from_oldworkspaceWebServiceTestsrc -verbose
3> -all会帮我们生成:
 
-all Specifies that interfaces, types , service, server , dummy
impl, client and ant script are generated.
 
4> -encoding utf8 / -encoding gbk解决生成的代码的乱码问题:
根据自己项目的编码情况,选则 gbk/utf8。乱码是指注释乱码。
 
5>最后的地址,可以换成xml文件在磁盘的地址:
wsdl2java -client -p com.hemr.hl7.ws.client -d D:from_oldworkspaceWebServiceTestsrc -verbose G:hL7MessageReveiver.xmll
 
 

免责声明:文章转载自《Cxf -wsdl2java 使用参数介绍》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇flask项目结构(六)快速开发后台flask-adminSpringBoot 入门下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

微信小程序访问webservice(wsdl)+ axis2发布服务端(Java)

0、主要思路:使用axis2发布webservice服务端,微信小程序作为客户端访问。步骤如下: 1、服务端: 首先微信小程序仅支持访问https的url,且必须是已备案域名。因此前期的服务器端工作需要先做好,本人是申请了个人域名(已备案),并使用阿里云服务器,然后申请免费SSL,通过配置tomcat完成支持https访问。此外,intellJ IDE的j...

根据wsdl反向生成webservice服务端(3种方法)

前言 正常情况下,都是我们项目组创建一个webservice服务端,客户通过我们提供的wsdl地址生成客户端并进行访问;但是最近和一个国企做接口对接,他们却只提供给我们wsdl,需要我们根据wsdl生成服务端,提供服务给他们。故有此文。 生成方式 通过wsdl生成服务端的方法总共有3种方法: l 使用soapUI生成 l 使用myeclipse的web...

SpringBoot + CXF快速实现SOAP WebService(支持Basic Auth)

唠叨两句 讲真,SOAP跟现在流行的RESTful WebService比起来显得很难用。冗余的XML文本信息太多,可读性差,它的请求信息有时很难手动构造,不太好调试。不过说归说,对某些企业用户来说SOAP的使用率仍然是很高的。 需求背景 接手维护的一个项目,最近客户想开放项目中的功能给第三方调用,而且接入方指定必须是SOAP接口。这项目原来的代码我看着头...

SpringBoot整合WebService

WebService是一个SOA(面向服务的编程)的架构,它是不依赖于语言,不依赖于平台,可以实现不同的语言间的相互调用,通过Internet进行基于Http协议的网络应用间的交互。其实WebService并不是什么神秘的东西,它就是一个可以远程调用的类,或者说是组件,把你本地的功能开放出去共别人调用。具体的说,Web Service可以让你的网站使用其他...

axis2开发webservice总结

需求环境:对接方公司提供wsdl文件,我方按照该wsdl文件开发服务端。 配置axis2开发环境,网上教程很多,不再啰嗦。环境搭好后执行wsdl2java -uri file:///C:/Users/lenovo/Desktop/ws/jc/UtcsService.wsdl -s -ss -ap -sd -ssi -d adb -o buildserver...

WebService如何根据WSDL文件转换成本地的C#类

WebService有两种使用方式,一种是直接通过添加服务引用,另一种则是通过WSDL生成。 添加服务引用大家基本都用过,这里就不讲解了。 那么,既然有直接引用的方式,为什么还要通过WSDL生成呢? 因为通过WSDL生成,就只有一个.cs 文件,便于管理,更简洁。 一、生成步骤 1. 打开vs开发控制台, 如下图: 2. 在控制台中输入如下指令 wsdl...