参考来源:https://www.cnblogs.com/frankliiu-java/articles/1641949.html 以及其它资源;
测试成功
一、配置服务端
1、下载apache-cxf-2.1.3.zip,
//下载包路径:http://search.maven.org/#search|gav|1|g:"org.apache.cxf" AND a:"apache-cxf" 注释:2017-12-15测试,还可以下载
导入以下包:
commons-logging-1.1.1.jar
geronimo-activation_1.1_spec-1.0.2.jar
geronimo-annotation_1.0_spec-1.1.1.jar
geronimo-javamail_1.4_spec-1.3.jar
geronimo-servlet_2.5_spec-1.2.jar
geronimo-ws-metadata_2.0_spec-1.1.3.jar
jaxb-api-2.1.jar
jaxb-impl-2.1.7.jar
jetty-6.1.9.jar
jetty-util-6.1.9.jar
neethi-2.0.4.jar
saaj-api-1.3.jar
saaj-impl-1.3.2.jar
wsdl4j-1.6.2.jar
wstx-asl-3.2.6.jar
XmlSchema-1.4.2.jar
xml-resolver-1.2.jar
cxf-2.1.3.jar
//调试单独下载的包
jaxws-api-2.0.jar
stax-api-1.0.1.jar
//spring.jar包
aopalliance-1.0.jar
spring-core-3.2.0.RELEASE.jar
spring-beans-3.2.0.RELEASE.jar
spring-context-3.2.0.RELEASE.jar
spring-web-3.2.0.RELEASE.jar
2、web.xml配置,增加下面的代码. 注释:由于编码问题,请吧《换成“<”
《!-- 配置cxf核心servlet -->
《servlet>
《servlet-name>CXFServlet《/servlet-name>
《servlet-class>org.apache.cxf.transport.servlet.CXFServlet《/servlet-class>
《load-on-startup>1《/load-on-startup>
《/servlet>
《servlet-mapping>
《servlet-name>CXFServlet《/servlet-name>
《url-pattern>/cxf/*《/url-pattern>
《/servlet-mapping>
3、spring.xml的增加以下配置
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="[....] //[....]代表其他的http参数
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
《!-- cxf.xml、cxf-extension-soap.xml、cxf-servlet.xml在包里面的 -->
《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"/>
《jaxws:endpoint id="helloWorld" implementor="cn.net.ssd.service.impl.HiServiceImpl" address="/helloWorld" />
《bean id="client" class="cn.net.ssd.service.IHiService" factory-bean="clientFactory" factory-method="create"/>
《bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
《property name="serviceClass" value="cn.net.ssd.service.IHiService"/>
《property name="address" value="http://localhost:8080/port/cxf/helloWorld"/>
《/bean>
4、java代码
IHiService.java接口编写
package cn.net.ssd.service;
import javax.jws.WebService;
@WebService
public interface IHiService {
String sayHi(String name);
}
HiServiceImpl.java类编写
package cn.net.ssd.service.impl;
import javax.jws.WebService;
import cn.net.ssd.service.IHiService;
@WebService(endpointInterface="cn.net.ssd.service.IHiService",serviceName="IHiService")
public class HiServiceImpl implements IHiService {
public String sayHi(String name) {
System.out.println(name);
return "返回数据test111";
}
}
二、用工具测试是否连通
1、网盘地址下载: 链接:http://pan.baidu.com/s/1gfGF2IB 密码:ycd2 //2017-12-14可以下载
2、测试成功,如图:
![](https://img2018.cnblogs.com/blog/638275/201905/638275-20190516103420636-2066169140.jpg)