几种常用的webservice客户端和spring集成的方法
项目需要,这两天系统要调一个webservice的服务,webservice的东西都扔了好几年了,怎么使用都忘得一干二净了。以前都是使用系统现成的框架掉一个方法就行了,现在几乎是从0开始一点一点搭建环境啊 由于只是调用服务,所以我这边只要实现一下spring环境下接入websevice就行了 第一中尝试的是使用spring ws的WebServiceTemplate 配置的方法如下: ????????<bean?id="xxxWebService"?class="org.springframework.ws.client.core.WebServiceTemplate"> ????????????<property?name="defaultUri"?value="http://XXX.net:8080"/> ????????</bean> 第二种尝试我用了jaxws 配置方法如下: ????<bean?id="xxxWebService"?class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"> ????????<property?name="serviceInterface"?value="com.xxx.UploadFileService"/> ????????<property?name="namespaceUri"?value="http://XXX.net:8080"/> ????????<property?name="wsdlDocumentUrl"?value="http://XXX.net:8080/XXXServicePort?WSDL"?/> ????</bean> 第3中我尝试的是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"?/>?? ????? ????<jaxws:client?id="xxxWebService"?serviceClass="com.xxx.UploadFileService"??? ????????????address="http://XXX.net:8080">?? ????</jaxws:client> 第4种我用的是xfire,也是最后项目采用的方法 ??<bean?id?="dwdsspWebService"?class?="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean"> ????????<property?name?="serviceClass"> ????????????<value>com.xxx.UploadFileService</value> ????????</property> ????????<property?name?="wsdlDocumentUrl"> ????????????<value>http://XXX.net:8080/XXXServicePort?WSDL</value> ????????</property> ????</bean> 参考文档:http://www.voidcn.com/article/p-ylfvwfef-xw.html http://www.voidcn.com/article/p-yvwnrvby-xw.html http://www.voidcn.com/article/p-khhirezz-baw.html http://www.voidcn.com/article/p-gvsvqzky-om.html http://www.voidcn.com/article/p-vfandhdb-bqx.html 总结一下,现在项目中很少用webservice了,所以一下子用起来还挺捉急,这里记录下集中常用的方法备忘一下,没有具体的对比各个方式优劣。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |