采用CXF 构建webservice
来源:互联网 发布:边际报酬递减规律算法 编辑:程序博客网 时间:2024/05/19 23:52
一般接口开发都会使用如 webservice,ftp ,sftp 的方式实现,如java 程序访问.net 程序,就不的不涉及到soa
开发步骤:
1.下载cxf 相关jar 包
2.在spring context配置文件中引入以下cxf配置
<import resource="classpath*:META-INF/cxf/cxf.xml" /><import resource="classpath*:META-INF/cxf/cxf-extension-soap.xml" /><import resource="classpath*:META-INF/cxf/cxf-servlet.xml" />
3.在web.xml中添加过滤器:
<servlet><servlet-name>CXFServlet</servlet-name><servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class></servlet><servlet-mapping><servlet-name>CXFServlet</servlet-name><url-pattern>/webservices/*</url-pattern></servlet-mapping>4.定义服务端WebService接口(下面直接使用了类定义,当然也可用接口定义) package com.jumbo.webservice.biaogan.service;import java.util.List;import javax.jws.WebParam;import javax.jws.WebService;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import com.jumbo.manager.warehouse.WareHouseManagerProxy;import com.jumbo.mq.MarshallerUtil;............................./*** 使用@WebService将接口中的所有方法输出为Web Service.* 可用annotation对设置方法、参数和返回值在WSDL中的定义.下面是定义了两个带参数的方法
* Please modify this class to meet your needs This class is not complete
*/
@WebService(serviceName = "BgService", targetNamespace = "http://www.jumbomart.cn/webservice/")
public class BGWebService {
protected static final Logger log = LoggerFactory.getLogger(BGService.class);
public String outboundToBz(@WebParam(name = "request") String xml) {
}
public String inboundToBz(@WebParam(name = "request") String xml) {
}
}
5.webservice 服务端配置
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
<bean id="jaxbBean" class="org.apache.cxf.jaxb.JAXBDataBinding" scope="prototype" />
<context:component-scan base-package="com.jumbo.webservice.biaogan.service">
<context:include-filter type="annotation"
expression="org.aspectj.lang.annotation.Aspect" />
</context:component-scan>
<bean id="bgService" class="com.webservice.service.BGWebService " />
<jaxws:endpoint id="bgAddress" implementor="#bgService" address="/bg" />
最后可以通过http://localhost:8080/testws/services/bg?wsdl 查看自动生成的wsdl 文件
wsdl 文档太长,略
6.可以通过eclipse webservice 插件来通过wsdl 文件自动构建客服端,从而向服务器发消息
- 采用CXF 构建webservice
- CXF构建webservice解析
- 采用CXF框架开发HelloWorld WebService客户端
- 使用CXF构建webservice和rest应用
- 使用CXF构建webservice和rest应用
- Eclipse+Maven+Spring+CXF 构建webservice 服务
- CXF+spring构建restful风格的webservice
- 基于SSM+CXF构建的RESTFul webservice
- spring + cxf 构建 webservice 接口入门
- Eclipse+Maven+Spring+CXF 构建webservice 服务
- 采用CXF解决webservice循环引用对象的问题
- ssh整合webservice cxf采用注解的方式+andriod客户端
- 采用CXF解决webservice循环引用对象的问题
- 【WebService框架-CXF】——CXF+Spring+自定义拦截器构建WebService服务端
- 【WebService框架-CXF】——CXF+Spring+Struts+自定义拦截器构建WebService客户端
- WebService-CXF
- CXF webservice
- CXF WebService
- 常用cmd命令
- 使用Axis编写WebService
- 除了技术我们还应该知道的
- 画正弦线
- Java I/O
- 采用CXF 构建webservice
- 虚拟机域的安装配置
- 安装SourceNavigator 6.0
- android json解析及简单例子
- 从DDOS说起:最优的服务器集群方案-PaceMaker
- java同步和互斥
- 趣题 do while continue
- 谁拿了最多奖学金
- C# attribute属性的例子