cxf http 代码自动生成
1.下载 cxf
直接进入镜像下载
http://mirrors.tuna.tsinghua.edu.cn/apache/cxf/3.1.12/apache-cxf-3.1.12.zip
2.配置 CXF 环境变量
CXF_HOME=E:/installFile/cxf/apache-cxf-3.1.12
在 CLASSPATH 后添加 %CXF_HOME%/lib;
在 Path 后添加 %CXF_HOME%/bin;
查看版本是否配置成功
wsdl2java -v
3.生成服务端代码
我这里做的是 http 协议,请确认 wsdl 文件中指定的协议类型为 http
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
打开 cmd 进入 wsdl 所在目录执行
wsdl2java -server -impl -encoding UTF8 -d E:\work\waikuai\pom\cxf\src\main\java HelloEsbService.wsdl
4.配置服务端
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <jaxws:endpoint id="userService"
implementor="com.midea.service.esbpro.abstraction.atomic.technology_helloesbservice.v1.HelloEsbServicePortImpl"
address="/userWS">
</jaxws:endpoint> </beans>
5.POM.XML
<cxf.version>3.1.</cxf.version> <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
6.web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app>
<display-name>Archetype Created Web Application</display-name> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext.xml
</param-value>
</context-param> <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<servlet>
<servlet-name>CXFService</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFService</servlet-name>
<url-pattern>/cxf/*</url-pattern>
</servlet-mapping> </web-app>
7.启动测试 访问
http://localhost:8015/cxf/cxf/userWS?wsdl
8.客户端代码生成
cmd 进入客户端源码目录执行
wsdl2java -keep http://localhost:8015/cxf/cxf/userWS?wsdl
或者执行
wsdl2java -client -impl -encoding UTF8 -d E:\work\waikuai\pom\cxf_client\src\main\java HelloEsbService.wsdl
9.打开生成的模拟客户端 _cliet 调用接口ok
这个client 没有集成 spring
10. 客户端 spring 配置
<bean id="client" class="com.midea.service.esbpro.abstraction.atomic.technology_helloesbservice.v1.HelloEsbService" factory-bean="clientFactory" factory-method="create"/>
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.midea.service.esbpro.abstraction.atomic.technology_helloesbservice.v1.HelloEsbService"/>
<property name="address" value="http://localhost:8015/cxf/cxf/userWS?wsdl"/>
</bean>
11. 查看wsdl2java 帮助
wsdl2java -help
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.) -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
cxf http 代码自动生成的更多相关文章
- webservice 服务端例子+客户端例子+CXF整合spring服务端测试+生成wsdl文件 +cxf客户端代码自动生成
首先到CXF官网及spring官网下载相关jar架包,这个不多说.webservice是干嘛用的也不多说. 入门例子 模拟新增一个用户,并返回新增结果,成功还是失败. 大概的目录如上,很简单. Res ...
- MyBatis代码自动生成
MyBatis的代码自动生成的功能,由于MyBatis属于一种半自动的ORM框架,所以主要的工作就是配置Mapping映射文件,但是由于手写映射文件很容易出错,所以可利用MyBatis生成器自动生成实 ...
- 代码自动生成工具_java版
项目结构: 这里要实现的功能是,当我们给出了bean,如:Admin,User,People等实体类后, 我想用代码自动生成我想要的代码,最后生成的效果: 也就是说为每一个bean都生成相应的Dao, ...
- mybatisGenerator 代码自动生成报错 Result Maps collection already contains value for BaseResultMap【转】
由于mybatis简单易学,比起Hibername来,更容易上手,代码也能自动生成.这几天研究了下代码自动生成的,参考: http://0609xiaohua.iteye.com/blog/14535 ...
- 代码自动生成工具MyGeneration之一(程序员必备工具)
代码自动生成工具MyGeneration之一(程序员必备工具) 转 分类: C#2008-08-06 18:12 16064人阅读 评论(12) 收藏 举报 工具数据库相关数据库stringbrows ...
- 基于eclipse的mybatis映射代码自动生成的插件
基于eclipse的mybatis映射代码自动生成的插件 分类: JAVA 数据库 工具相关2012-04-29 00:15 2157人阅读 评论(9) 收藏 举报 eclipsegeneratori ...
- 基于eclipse的mybatis映射代码自动生成的插件http://blog.csdn.net/fu9958/article/details/7521681
基于eclipse的mybatis映射代码自动生成的插件 分类: JAVA 数据库 工具相关2012-04-29 00:15 2157人阅读 评论(9) 收藏 举报 eclipsegeneratori ...
- Spring Boot (七)MyBatis代码自动生成和辅助插件
一.简介 1.1 MyBatis Generator介绍 MyBatis Generator 是MyBatis 官方出品的一款,用来自动生成MyBatis的 mapper.dao.entity 的框架 ...
- Mybatis Generator代码自动生成(实体类、dao层、映射文件)
写了一段时间增删改查有点厌烦,自己找了下网上的例子鼓捣了下自动生成. 首先得有一个配置文件: generatorConfig.xml <?xml version="1.0" ...
随机推荐
- java.lang.RuntimeException: Unable to start activity ComponentInfo……AppCompat does not support the current theme features
Android测试时出现闪退的问题,出现了如下所示异常: java.lang.RuntimeException: Unable to start activity ComponentInfo{thon ...
- Debian初始化配置
1.解决中文显示乱码windows的宋体文件上传到debian的字体目录,并运行dpkg-reconfigure locales命令来设置系统的字体root@debian:~# mv simsun.t ...
- python模块--pickle&json&shelve
使用file文件处理时,写入的必须是str ,否则会报错. 例如:要把一个字典写入文件,写入时会报错 ,就算转换成str格式写入,读取的时候也不能按照dict格式读. >>> inf ...
- pycharm配置appium 提示unsrsloved reference
1.如:进入C:\Users\Administrator\PycharmProjects\project\venv 输入:在cmd 下进入 venv 输入 Scripts\activate 回车 ...
- Windows下如何使用Heroku
1. 安装 进入https://devcenter.heroku.com/articles/heroku-cli#windows,选择对应版本安装 安装后使用heroku -v可检查版本号 2. 登陆 ...
- 『计算机视觉』Mask-RCNN_推断网络终篇:使用detect方法进行推断
一.detect和build 前面多节中我们花了大量笔墨介绍build方法的inference分支,这节我们看看它是如何被调用的. 在dimo.ipynb中,涉及model的操作我们简单进行一下汇总, ...
- CSS text-decoration 属性
定义和用法 text-decoration 属性规定添加到文本的修饰. 注释:修饰的颜色由 "color" 属性设置. 说明 这个属性允许对文本设置某种效果,如加下划线.如果后代元 ...
- volatile原理解析
Java并发编程:volatile关键字解析 volatile 有序性.可见性 volatile可以保证一定程度上有序性,即volatile前面的代码先于后面的代码先执行. 但是前.后代码,各自里面的 ...
- mac bash 下使用vi 快捷方式——因为没有alt键 所以没有办法 用vi模式也非常方便的
set -o emacs ##切到emacs模式 set -o vi ##切到vi模式 set -o ## 查看当前选项的设置状态 所以你只需要在.bashrc下加入 set -o vi 然后,使用E ...
- js 时间戳转特定格式的日期
var Tools = {}; Tools.formatDate = function (fmt,timestamp) { if(timestamp){ var date = new Date(par ...