1. 采用webservice原因
公司的几个项目都用到了同一个服务,所以把这个服务做成了webservice
2. 实现webservice技术
采用的cxf,之所以选择cxf不选择axis,是因为cxf对spring支持
3. cxf梳理
3.1 之前参考原来的代码也会使用webservice服务,但不知道所以然,现在有点时间,了解一下cxf,现在归纳一下自己知道的,以防以后忘记。
3.2 简单的例子可以参考http://cxf.apache.org/docs/a-simple-jax-ws-service.html
3.3 1)服务端
创建webservice 服务端,创建一个接口和实现类,在接口和实现类中增加要发布的方法,然后通过xml文件发布出去,形式一如下:
<bean id="hello" class="demo.spring.HelloWorldImpl"/>
<jaxws:endpoint id="helloWorld" implementor="#hello" address="/HelloWorld" />
形式一是spring托管方式
形式二如下:
<jaxws:endpoint id="helloWorld" implementor="demo.spring.HelloWorldImpl"
address="/HelloWorld" />
访问http://IP:端口/项目名,如果网页能正常打开,说明服务发布成功
2)客户端
在客户端需要建立和服务端一样的接口,目的是客户端可以识别服务端提供的接口和方法
客户端在xml文件中配置如下
<jaxws:client id="helloClient"
serviceClass="demo.spring.HelloWorld"
address="http://localhost:8080/项目名/HelloWorld" />
或
<bean id="helloClient" class="demo.spring.HelloWorld" factory-bean="clientFactory"
factory-method="create" />
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="demo.spring.HelloWorld" />
<property name="address" value="http://localhost:8080/项目名/HelloWorld" />
</bean>
然后项目加载这个xml文件,获得helloClient Bean,然后调用相应的webservice方法
分享到:
相关推荐
WebService CXF 详细教程 加上自带CXF文件
webservice 包括 cxf wss xml http等jar欢迎下载 亲测可用
WebService CXF学习——入门篇 1.CXF由来 2.HelloWorld 3.WSDL描述 WebService CXF学习——进阶篇 1.SOAP讲解 2.JAX-WS讲解 3.对象传递 WebService CXF学习——高级篇(一)(二) 1.整合Spring框架 2.CXF...
cxf写的一个helloworld demo
webservice cxf 客户端创建实例
现在主流的webService框架,一个是axis2,一个是cxf,本资源是基于cxf框架的简单例子
WebService CXF 开发教程 eclipse插件配置 开发及代码说明
WebService CXF 用了一天时间找,官网打不开,国内要积分,下下来又永不了。最后终于搞到手,上传上来分享给大家。 jdk版本 CXF版本 java 9及以上 3.3.x java 8 3.x java 7 2.2x --- 3.2之前版本 java 6 3.1 ...
SpringBoot WebService cxf接口发布以及logbok日志集成, 希望对学习的小伙伴们有帮助
webservice cxf apache-cxf-2.2.6 开发包
Java 调用webservice cxf客户端调用demo和服务端,包含jar包,服务端发布后直接用客户端调用
webservice cxf spring整合返回list,bean,string,json,xml项目完整实例
webservice cxf spring jar包大全,下载,超好用的
webservice cxf 简单使用(只有工程里没有lib包)
webservice cxf jar包。 没有验证哪些是多余的 简单demo可以运行成功
WebService CXF使用说明,里面包含权限控制。
最近公司要用到webservice ,最后经过对比、考虑选择cxf,最近在网上找了一些资料写的很零散,如果是新手的话还得查很多资料,比较麻烦,所以将cxf开发中使用的资料和要用到的工具与大家分享,并附上自己测试的demo,以...
该项目集成 webservice cxf eclipse endpoint 导入eclipse直接可以运行
webService CXF不依赖Spring集成,包含客户端、服务端代码。使用3.1.7版的CXF包。demo可以直接运行