spring与cxf整合开发webservice服务接口
2017-08-09 13:48
489 查看
1、pom.xml文件中加入最新的jar:
2、编写webservice接口:
3、编写实现VerifyWS接口的类:
4、recourse目录下,新建applicationContext-webservice.xml配置文件:
5、web.xml文件中,增加如下配置:
6、启动服务,浏览器输入:
<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>
2、编写webservice接口:
import javax.jws.WebMethod; import javax.jws.WebService; /** * Created by ssl on 2017/8/8. */ @WebService public interface VerifyWS { @WebMethod ResultInfo verity(VerifyInfo verifyInfo); }
3、编写实现VerifyWS接口的类:
import com.szitrus.smp.gateway.service.GatewayService; import com.szitrus.smp.service.AppService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; /** * Created by ssl on 2017/8/8. */ public class VerifyWSImpl implements VerifyWS { @Autowired private AppService appService; @Autowired private GatewayService gatewayService; @Value("#{APP_PROP['local.seal.dir']}") private String local_seal_dir; @Override public ResultInfo verity(VerifyInfo verifyInfo) { ResultInfo resultInfo = new ResultInfo(); resultInfo.setCode("1");//0验证成功,1验证失败 resultInfo.setMessage("验证失败,服务端异常"); //编写业务逻辑··· //``````` return resultInfo; } }
4、recourse目录下,新建applicationContext-webservice.xml配置文件:
<?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"/> <jaxws:endpoint id="makeSealService" implementor="com.szitrus.smp.gateway.webservice.seal.MakeSealWSImpl" address="/makeSealService"/> <jaxws:endpoint id="verifyService" implementor="com.szitrus.smp.gateway.webservice.verify.VerifyWSImpl" address="/verifyService"/> </beans>
5、web.xml文件中,增加如下配置:
<!-- webservice --> <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>/webservice/*</url-pattern> </servlet-mapping>
6、启动服务,浏览器输入:
http://127.0.0.1:8080/[项目名称]/webservice/verifyService?wsdl。完成。
相关文章推荐
- Android开发中调用Spring CXF整合发布的WebService接口为什么抛出异常错误?
- CXF与Spring整合开发WebService服务
- Spring整合CXF配置WebService服务发布
- (四)CXF整合Spring发布WebService服务
- spring整合cxf开发webservice
- CXF 开发RESTful WebService服务(Spring+JPA服务端,JAXRS2.0+WebClient客户端)
- 9、利用Hessian和Spring整合开发WebService服务
- WebService技术总结(五):CXF整合Spring开发
- spring boot整合cxf发布webservice服务和spring boot整合cxf客户端调用webservice服务
- spring和cxf框架整合实现webService服务
- SpringBoot整合CXF开发基于soap协议的服务
- webService(CXF开发SOAP应用,CXF整合spring)未完待续
- Maven+SpringMVC+CXF整合实现webservice服务的发布与调用
- CXF+Spring+Tomcat开发webservice接口,并添加SSL双向认证
- Spring整合CXF之发布WebService服务
- CXF3.0.4与spring整合开发Webservice功能的web项目
- spring整合cxf方式发布的rest webservice,调用接口
- SpringBoot整合cxf发布WebService服务和客户端调用WebService服务
- (四)整合spring与cxf的webservice开发
- Spring整合CXF之发布WebService服务