初学webservices服务器端 cxf
程序员文章站
2022-03-27 08:52:15
学习内容:初学webservices cxf学习产出: org.apache.cxf <...
学习内容:
初学webservices cxf
学习产出:
<!-- cxf-->
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-transports-http-jetty -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>3.2.7</version>
</dependency>
web.xml
<!-- CXF -->
<servlet>
<servlet-name>cxf</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
spring.xml
<context:component-scan base-package="com.hyjx.business.interfacelr"/>
<import resource="spring-cxf.xml"/>
spring-cxf.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-4.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="resultimpServiceImpl" class="com.hyjx.business.interfacelr.resultimpWS.ResultimpServiceImpl"/>
<jaxws:server id="resultimpService" address="/resultimpWS">
<jaxws:serviceBean>
<ref bean="resultimpServiceImpl"/>
</jaxws:serviceBean>
</jaxws:server>
</beans>
接口编写
package com.hyjx.business.interfacelr.resultimpWS;
import javax.jws.WebService;
import com.fasterxml.jackson.core.JsonProcessingException;
@WebService
public interface ResultimpService {
public ResultMsgModel addresult(ResultimpModel model) throws JsonProcessingException;
public ResultMsgModel updateResult(ResultimpModel model) throws JsonProcessingException;
}
import javax.annotation.Resource;
import javax.jws.WebService;
@WebService
@Component
public class ResultimpServiceImpl implements ResultimpService {
遇到问题
1.生成接口是需要先配置一下环境
学习地址
https://my.oschina.net/huangyong/blog/287791
本文地址:https://blog.csdn.net/heixiaozhi666/article/details/111994625
下一篇: SpringMVC框架(1)