CXF生成客户端

前两天突然发现网上有的CXF命令生成的客户端不全,只会生成两个文件,可能是和AXIS2的搞混了,一个文件中包含着发送所需的类,一般包含多个内部类,还有一个是发送所用的类,这样生成的客户端可读性不太好,因为基本上所有类都在一个类中,查看或查找不太方便,后续的自己或者其他人的维护也不方便,特此在这记录一下。上官网看了下文档,Axis2生成的是两个文件,Axis1生成的类是分开的。

wsdl2java -p com.service.cxf -d d:\CXFGeneratorClient "http://test.xxx.com/xxxx/ws/contract.wsdl"

生成客户端时,常用的命令有, -p, package-name,要生成的包名,比如"com.service.cxf", -d,output-directory,生成客户端后要将包存放在哪,比如"d:\CXFGeneratorClient", -client,这个选项可以有也可以没有,当没有的时候就是正常生成客户端,有的时候会多生成一个包含main方法的测试类,可以直接调用测试,查看接口联通情况,-encoding,指定接口的编码,比如-encoding utf-8 。

附选项说明
Options:

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

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

-wv
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
Specify he WSDL service name to use for the generated code.
Also, optionally specify the WSDL namespace.

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

-reserveClass *
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
Specify catalog file to map the imported wsdl/schema.

-d
Specify the directory into which the code is placed.

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

-classdir
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
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>
-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 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

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.

-suppress-generated-date

Prevents dumping current date as part of javadocs of the Java files generated.

-maxExtensionStackDepth <maxExtensionStackDepth>

The maximum stack depth allowed when parsing schema extensions. The default is 5.

-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&wsdlList=true on a cxf server.

posted @ 2020-10-09 11:35  iHADream  阅读(659)  评论(0编辑  收藏  举报