当前位置:我的异常网» Web前端 » java xfire+ spring 公布服务端web service 以及客
java xfire+ spring 公布服务端web service 以及客户端调用
www.myexceptions.net 网友分享于:2013-09-08 浏览:34次
java xfire+ spring 发布服务端web service 以及客户端调用
发现,在客户端调用 结合spring的时候,
log中打印出:Retrieving document at 'null'.
目前属于 xfire的一个bug,xfire版本:1.2.6.
http://jira.codehaus.org/browse/XFIRE-1088
从bug上 还没有看到相应的fix的版本。
====================================
服务端 编写:
class="org.codehaus.xfire.addressing.AddressingInHandler" />
class="org.codehaus.xfire.spring.ServiceBean">
class="org.codehaus.xfire.spring.ServiceBean">
-------------------------------
通过web url
http://localhost:8080/xfiremsg/services
可以看到发布的webservice。
客户端调用:
-------------
1.spring:结合:
com.mjp.ws.client.IHelloWs
http://localhost:8080/xfiremsg/services/IHelloWs?wsdl
private static void run1() {
System.out.println("-------run1 start-------------------");
try {
Service serviceModel = new ObjectServiceFactory()
.create(IHelloWs.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());
String url = "http://localhost:8080/xfiremsg/services/IHelloWs";
IHelloWs cws = (IHelloWs) factory.create(serviceModel, url);
String result = cws.hello("mjp");
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("-------run1 end-------------------");
}
private static void run2() {
System.out.println("-------run2 start-------------------");
try {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"applicationContext.xml");
IHelloWs cws = (IHelloWs) ctx.getBean("helloService");
String result = cws.hello("mjp");
System.out.println(result);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("-------run2 end-------------------");
}
----------------------------
客户端调用时 :首先将 发布服务的接口,输入参数对象,返回对象对于的自定义类,接口类,打成一个jar,加入到工程里边
文章评论