Spring3.2 + cxf1.7.3整合

参考:http://tsinglongwu.iteye.com/blog/832704
测试调试工具介绍
1.SoapUI1.6 http://webservices.ctocio.com.cn/tips/263/7817763.shtml
2.TestMaker http://webservices.ctocio.com.cn/tips/263/7817763_2.shtml
3.WebServiceStudio http://demo.tc/Post/529
SoapUI支持eclipse插件

pom.xml

提供服务端
web.xml

非注解:applicationContext.xml

<jaxws:endpoint>有三个属性id, implementor和address。
id”指定这个Bean在Spring上下文中唯一的标识。
implementor”指定了这个Web Service的实现类。
address”指定了服务在Web服务器上发布的地址。这个地址可以包含ip和端口的完整地址,也可以是只包含相对路径的地址。

注解:applicationContext.xml

注意: 同时应该在实现类加上@Component注解.

接口:使用@WebService注解,表明这个接口就是对外提供的服务.

实现类:使用@WebService(endpointInterface = “com.webservices.IHelloWorld”, serviceName = “HelloWorld”)注解,表明这个是IHelloWorld服务的实现类,并提供发布到外部,服务名字是HelloWorld

也可以使用@Component去注解实现类,才能使用注解方式.

运行工程,进入:http://localhost:8080/webservice/HelloWorld?wsdl ,得到的wsdl

则表示服务端的webservice已经部署成功,就等着客户端来访问.

客户端:
pom.xml, 类似服务端的pom.xml,只是名字有差别而已

使用命令得到基本的类:
wsdl2java  -d /mnt/d/vmware_shared_folder/workspace/webserviceclient/src/main/java -p com.websercices.client -frontend jaxws21 http://localhost:8080/webservice/HelloWorld?wsdl

applicationContext.xml

注意:
1. org.apache.cxf.jaxws.JaxWsProxyFactoryBean要知道提供服务的接口和URL.
2. <property name=”address” value=”http://localhost:8080/webservice/HelloWorld” />中的/HelloWorld要与服务器端applicationContext.xml中的<jaxws:endpoint id=”helloWorld” implementor=”#hello” address=”/HelloWorld” />的address属性对应。

建立一个测试类:

运行客户端测试类,得到结果: Hello 猪头!