CXF提供从wsdl文件生成java代码的工具脚本:%CXF_HOME%\bin\wsdl2java.bat
脚本参数详解:
-?,-h,-help | Displays the online help for this utility and exits. |
-fe frontend-name | Specifies the frontend. Default is JAXWS. Currently supports only JAXWS frontend and a "jaxws21" frontend to generate JAX-WS 2.1 compliant code. |
-db databinding-name | Specifies the databinding. Default is jaxb. Currently supports jaxb, xmlbeans, sdo (sdo-static and sdo-dynamic), and jibx. |
-wv wsdl-version | Specifies the wsdl version .Default is WSDL1.1. Currently suppports only WSDL1.1 version. |
-p [ wsdl-namespace= ] PackageName | Specifies zero, or more, package names to use for the generated code. Optionally specifies the WSDL namespace to package name mapping. |
-sn service-name | The WSDL service name to use for the generated code. |
-b binding-name | Specifies JAXWS or JAXB binding files or XMLBeans context files. Use multiple -b flags to specify multiple entries. |
-catalog catalog-file-name | Specify catalog file to map the imported wsdl/schema |
-d output-directory | Specifies the directory into which the generated code files are written. |
-compile | Compiles generated Java files. |
-classdir compile-class-dir | Specifies the directory into which the compiled class files are written. |
-client | Generates starting point code for a client mainline. |
-clientjar jar-file-name | Generates the jar file which contains all the client classes and wsdl;the specified wsdlLocation won't work when the -clientJar is defined. |
-server | Generates starting point code for a server mainline. |
-impl | Generates starting point code for an implementation object. |
-all | Generates all starting point code: types, service proxy, service interface, server mainline, client mainline, implementation object, and an Ant build.xml file. |
-ant | Specify to generate an Ant build.xml script. |
-autoNameResolution | Automatically resolve naming conflicts without requiring the use of binding customizations. |
-defaultValues=[DefaultValueProvider impl] | Specifies that default values are generated for the impl and client. You can also provide a custom default value provider. The default provider is RandomValueProvider |
-nexclude schema-namespace [=java-packagename] | Ignore the specified WSDL schema namespace when generating code. This option may be specified multiple times. Also, optionally specifies the Java package name used by types described in the excluded namespace(s). |
-exsh (true/false) | Enables or disables processing of implicit SOAP headers (i.e. SOAP headers defined in the wsdl:binding but not wsdl:portType section.) Processing the SOAP headers requires the SOAP binding jars available on the classpath which was not the default in CXF 2.4.x and older. You may need to add a dependency to cxf-rt-binding-soap for this flag to work. Default is false. |
-dns (true/false) | Enables or disables the loading of the default namespace package name mapping. Default is true andhttp://www.w3.org/2005/08/addressing=org.apache.cxf.ws.addressing namespace package mapping will be enabled. |
-dex (true/false) | Enables or disables the loading of the default excludes namespace mapping. Default is true. |
-validate | Enables validating the WSDL before generating the code. |
-keep | Specifies that the code generator will not overwrite any preexisting files. You will be responsible for resolving any resulting compilation issues. |
-wsdlLocation wsdlLocation | Specifies the value of the @WebServiceClient annotation's wsdlLocation property. |
-xjc<xjc args> | Specifies a comma separated list of arguments that are passed directly to the XJC processor when using the JAXB databinding. A list of available XJC plugins can be obtained using -xjc-X. |
-noAddressBinding | For compatibility with CXF 2.0, this flag directs the code generator to generate the older CXF proprietary WS-Addressing types instead of the JAX-WS 2.1 compliant WS-Addressing types. |
-v | Displays the version number for the tool. |
-verbose | Displays comments during the code generation process. |
-quiet | Suppresses comments during the code generation process. |
-exceptionSuper | superclass for fault beans generated from wsdl:fault elements (defaults to java.lang.Exception) |
-reserveClass classname | Used with -autoNameResolution, defines a class names for wsdl-to-java not to use when generating classes. Use this option multiple times for multiple classes. |
-allowElementReferences<=true> | (or -aer) If true, disregards the rule given in section 2.3.1.2(v) of the JAX-WS 2.2 specification disallowing element references when using wrapper-style mapping. |
-asyncMethods=foo,bar,... | List of subsequently generated Java class methods to allow for client-side asynchronous calls, similar to enableAsyncMapping in a JAX-WS binding file. |
-bareMethods=foo,bar,... | List of subsequently generated Java class methods to have wrapper style (see below), similar to enableWrapperStyle in JAX-WS binding file. |
-mimeMethods=foo,bar,... | List of subsequently generated Java class methods to enable mime:content mapping, similar to enableMIMEContent in JAX-WS binding file. |
-faultSerialVersionUID <fault-serialVersionUID> | How to generate suid of fault exceptions. Use NONE, TIMESTAMP, FQCN, or a specific number. Default is NONE. |
-mark-generated | Adds the @Generated annotation to classes generated. |
wsdlurl | The path and name of the WSDL file to use in generating the code. |
参考地址:http://cxf.apache.org/docs/wsdl-to-java.html
【举例】
wsdl2java HelloWorld.wsdl
wsdl2java -p com.mycompany.greeting Greeting.wsdl
wsdl2java -client HelloWorld.wsdl
wsdl2java -server -b "binding.xml" -d d:\cxf sample.wsdl
SERVER端:
wsdl2java -b cxf_binding.xml -catalog cxf_catalog.xml -d server\src -server -impl -all -frontend jaxws21 -encoding utf-8 -autoNameResolution -keep example.wsdl
CLIENT端:
wsdl2java -b cxf_binding.xml -catalog cxf_catalog.xml -d client\src -client -impl -all -frontend jaxws21 -encoding utf-8 -autoNameResolution -keep example.wsdl
-impl:生成WS发布接口的实现类
-frontend jaxws21:使用JAX-WS 2.1
-encodng:生成文件的编码格式
常见问题:
1. 如何映射xsd:dateTime 到 java.util.Date 而不是 XMLGregorianCalendar ?
<jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <jxb:bindings schemaLocation="file:<path><name>.xsd" node="/xs:schema"> <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> </jxb:bindings> </jxb:bindings>
2.如何将属性的类型直接映射为JAVA类型而不是JAXBElement?
<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 generateElementProperty="false" > </jxb:globalBindings> </jaxws:bindings> </jaxws:bindings>
3.常见绑定文件及参数解释。
<?xml version="1.0" encoding="UTF-8"?> <jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1"> <jxb:globalBindings fixedAttributeAsConstantProperty="true" typesafeEnumMaxMembers="300" typesafeEnumMemberName="generateName" enableFailFastCheck="false" generateIsSetMethod="false" underscoreBinding="asCharInWord" choiceContentProperty="false" 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> </jxb:bindings>
相关推荐
使用cxf wsdl2java生成webservice客户端命令
apache CXF wsdl2java工具使用说明
NULL 博文链接:https://hongyegu.iteye.com/blog/637103
CXF提供的wsdl2java工具创建客户端的详细步骤
抛出无法找到主类:org.apache.axis.wsdl.WSDL2Java(Throws Could not find main class: org.apache.axis.wsdl.WSDL2Java)。 添加本文的jar包压缩包解压出来的所有jar包到当前使用的java.exe 命令的lib目录下的ext...
apache-cxf将wsdl生成java文件
cxf java代码生成 wsdl文件 ,wsdl文件生成 java代码,相关博文: http://blog.csdn.net/dream_broken/article/details/35331949
注意: 1.如果想学习java优先请...2.包含一个eclipse工程以及一个ppt,ppt详细说明了实现的步骤。 3.设计中重点考察了schema validate的配置与实现,后续更高级的相关知识敬请关注 http://blog.csdn.net/harrison2010
wsdl2java源码建造状态 CXF客户端 介绍 有几个不同的插件可以使用 grails 来使用 SOAP Web 服务,但目前没有一个可以处理缓存端口引用的问题。 ws-client 插件可以工作,但它的局限性在于它如何创建和使用 wsdl。 它...
JAVA7和JAVA8对应CXF资源 WebService CXF 用了一天时间找,官网打不开,国内要积分,下下来又永不了。最后终于搞到手,上传上来分享给大家。 jdk版本 CXF版本 java 9及以上 3.3.x java 8 3.x java 7 2.2x --- ...
wsdl2java源码sbt-cxf-wsdl2java 一个 sbt 插件,用于使用 cxf 从 WSDL 生成 java 工件 要求 快速开始 将插件添加到project/plugins.sbt : resolvers + = " Sonatype Repository " at " ...sbt-cxf-wsdl2java ...
wsdl2java源码Camel-CXF SOAP 客户端演示(使用 2 路 SSL) 此存储库包含一个示例 Camel-CXF 项目,该项目演示了使用 2 向 SSL(客户端身份验证)的客户端 SOAP 请求/回复。 入门 首先,将此存储库克隆到您的本地...
NULL 博文链接:https://jeooo-li.iteye.com/blog/471745
CXF后,并配置完成相关环境变量,通过wsdl2java生成对应的Java代码,实现方式有很多,这里推荐两种常用方式。 在拥有WSDL和XSD的目录,执行wsdl2java命令以后,将得到的Java代码拷贝至代码工程源代码路径 本例为...
wsdl2java源码springboot-apachecxf-client 本项目演示了如何在Springboot中实现apachecxf客户端,以及如何为客户端调用生成wsdltojava。 Springboot-apachecxf-jaxws 示例 此应用程序展示了如何使用 apachecxf ...
wsdl2java源码原作者注 该插件不再由其创建者维护。 这个存储库只是一个分支,将被动维护以跟上我依赖它的项目。 wsdl2java gradle 插件 // TODO 采用自述文件 用于从 wsdl 生成 java 的 Gradle 插件,在引擎盖下...
wsdl2java源码零 XML 配置的 Spring Boot 和 CXF 集成 示例项目展示了在创建具有独立 Java 配置的 JAX-WS SOAP Web 服务时如何集成 Spring Boot 和 CXF。 如何运行: mvn spring-boot:run Web 服务将部署在: ...
利用wsdl2java工具和SoapUI工具生成webservice的客户端代码 Java实现登陆验证调用 压缩包里包括需要的所有文件,供需要的同学使用 1.apache-cxf-3.3.7 2.SoapUI 5.4.0-EB 3.生成代码的教程 4.获取service调用的...
wsdl2java源码Apache CXF 是一个开源服务框架,可帮助使用前端编程 API(如 JAX-WS)构建和开发服务。 在本教程中,我们将了解如何将 CXF 与 Spring Boot 集成以构建和运行 Hello World SOAP 服务。 在整个示例中,...
wsdl2java gradle插件 用于在wsdl中生成Java的Gradle插件,在后台使用cxf,并使用与来自apache-cxf的maven wsdl-2-java插件相同的选项。 可从Bintray下载插件二进制文件: ://bintray....