加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

org.apache.cxf.interceptor.Fault: Could not send Message,问题解决

(2017-05-24 18:56:06)
问题描述:
     开发环境:eclipse-jee-luna-R-win32+jdk1.7 32位+apache-tomcat-7.0.29+apache-cxf-3.1.10
     出现情形:用cxf开发了服务器端,服务器启动后可以正常访问wsdl,但是通过cxf生成客户端进行访问时报错,错误内容如下:
五月 24, 2017 6:27:41 下午 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http://ws.day02_ws_cxf_spring.atguigu.com/}OrderWSService from WSDL: http://localhost:8080/ws_cxf_spring_server/orderws1?wsdl
五月 24, 2017 6:27:42 下午 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://ws.day02_ws_cxf_spring.atguigu.com/}OrderWSService#{http://ws.day02_ws_cxf_spring.atguigu.com/}getOrderById has thrown exception, unwinding now
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:263)
     at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:462)
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:365)
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:318)
     at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:95)
     at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
     at com.sun.proxy.$Proxy31.getOrderById(Unknown Source)
     at com.pxm.client.test.ClientTest.test1(ClientTest.java:24)
     at com.pxm.client.test.ClientTest.main(ClientTest.java:15)
Caused by: java.net.MalformedURLException: no protocol: dummy
     at java.net.URL.(URL.java:585)
     at java.net.URL.(URL.java:482)
     at java.net.URL.(URL.java:431)
     at org.apache.cxf.transport.http.HTTPConduit.setupURL(HTTPConduit.java:691)
     at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:466)
     at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46)
     ... 10 more
Exception in thread "main" javax.xml.ws.WebServiceException: Could not send Message.
     at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
     at com.sun.proxy.$Proxy31.getOrderById(Unknown Source)
     at com.pxm.client.test.ClientTest.test1(ClientTest.java:24)
     at com.pxm.client.test.ClientTest.main(ClientTest.java:15)
Caused by: java.net.MalformedURLException: no protocol: dummy
     at java.net.URL.(URL.java:585)
     at java.net.URL.(URL.java:482)
     at java.net.URL.(URL.java:431)
     at org.apache.cxf.transport.http.HTTPConduit.setupURL(HTTPConduit.java:691)
     at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:466)
     at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:46)
     at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
     at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:462)
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:365)
     at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:318)
     at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:95)
     at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
     ... 3 more
客户端访问代码如下:
     public static void test1(){
           JaxWsProxyFactoryBean factoryBean=new JaxWsProxyFactoryBean();
           factoryBean.setServiceClass(OrderWS.class);
           factoryBean.setWsdlURL("http://localhost:8080/ws_cxf_spring_server/orderws1?wsdl");
           OrderWS service=(OrderWS) factoryBean.create();
           service.getOrderById(1);
     }
解决方案:
通过在网上查找解决方案,查找到一个类似的问题,得到启发,将factoryBean.setWsdlURL("http://localhost:8080/ws_cxf_spring_server/orderws1?wsdl");
修改为
factoryBean.setAddress("http://localhost:8080/ws_cxf_spring_server/orderws1");之后就能够正常访问了,后我又测试了一下,修改为
factoryBean.setAddress("http://localhost:8080/ws_cxf_spring_server/orderws1?wsdl");也是能够正常访问的。

下面是我寻找解决方案时网上搜索到比较有帮助的一个,分享给大家:

个人感悟:
如果遇到相同的问题,可以在
factoryBean.setWsdlURL("http://localhost:8080/ws_cxf_spring_server/orderws1?wsdl");
factoryBean.setAddress("http://localhost:8080/ws_cxf_spring_server/orderws1");
factoryBean.setAddress("http://localhost:8080/ws_cxf_spring_server/orderws1?wsdl");
之间相互切换测试。









0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有