Albert's 实践记录
Java、Perl、Shell、& ……
posts - 0,  comments - 0,  trackbacks - 0
在看Apache CXF的文档,按照其中的步骤写了个入门例子,在运行Client调用服务时,抛出异常:

org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:
48)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:
236)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:
471)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:
301)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:
253)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:
73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:
121)
at $Proxy45.sayHi(Unknown Source)
at com.sg.webservice.client.Client.main(Client.java:
57)
Caused by: java.net.MalformedURLException: Invalid address. Endpoint address cannot be 
null.
at org.apache.cxf.transport.http.HTTPConduit.getURL(HTTPConduit.java:
803)
at org.apache.cxf.transport.http.HTTPConduit.getURL(HTTPConduit.java:
788)
at org.apache.cxf.transport.http.HTTPConduit.setupURL(HTTPConduit.java:
715)
at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:
490)
at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage

Client类的部分代码如下:
private static final QName SERVICE_NAME 
= new QName("http://server.webservice.com/""HelloWorld");
private static final QName PORT_NAME 
= new QName("http://server.webservice.com/""HelloWorldPort");


出错的原因在于SERVICE_NAME和PORT_NAME有误,因为我的Server类所在的包为com.mycompany.server,而不是com.webservice,server,所以,把SERVICE_NAME和PORT_NAME的namespaceURI改为与包路径相反即可:
private static final QName SERVICE_NAME 
= new QName("http://server.mycompany.com/""HelloWorld");
private static final QName PORT_NAME 
= new QName("http://server.mycompany.com/""HelloWorldPort");



posted on 2009-11-03 12:39 ouxingning 阅读(1350) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

<2025年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

留言簿

文章分类

文章档案

搜索

  •  

最新评论