Albert's 实践记录
Java、Perl、Shell、& ……
BlogJava
首页
新文章
新随笔
聚合
管理
posts - 0, comments - 0, trackbacks - 0
试用CXF,遭遇MalformedURLException异常
在看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)
编辑
收藏
新用户注册
刷新评论列表
只有注册用户
登录
后才能发表评论。
网站导航:
博客园
IT新闻
Chat2DB
C++博客
博问
管理
<
2025年7月
>
日
一
二
三
四
五
六
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
留言簿
给我留言
查看公开留言
查看私人留言
文章分类
Java
Perl
Shell
Web(1)
文章档案
2009年11月 (1)
2009年10月 (1)
搜索
最新评论