当前位置: 代码迷 >> Web Service >> .net 调用 cxf接口报错,求大神帮忙参考下,100分
  详细解决方案

.net 调用 cxf接口报错,求大神帮忙参考下,100分

热度:171   发布时间:2016-05-02 02:19:11.0
.net 调用 cxf接口报错,求大神帮忙参考下,100分求助
本帖最后由 wj38775428 于 2014-08-04 10:14:39 编辑
我在服务引用中添加了接口,然后调用接口中的方法,报错如下
用户代码未处理 System.ServiceModel.ProtocolException
  HResult=-2146233087
  Message=响应消息的内容类型 multipart/related; type="application/xop+xml"; boundary="----=_Part_0_4315167.1407191370328"; start="<[email protected]>"; start-info="text/xml" 与绑定(text/xml; charset=utf-8)的内容类型不匹配。如果使用自定义编码器,请确保正确实现 IsContentTypeSupported 方法。响应的前 627 个字节为:“
------=_Part_0_4315167.1407191370328
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:GetCkxxResponse xmlns:ns1="http://server.webservice.yuyue.dongcheng.asop.com/"><return>2014年08月05日,已预约到 09:24:00,已预约到 13:12:00,1,1,星期二</return><return>2014年08月06日,已预约到 09:06:00,已预约到 13:00:00,1,1,星期三</return></ns1:GetCkxxResponse></soap:Body></soap:Envelope>
------=_Part_0_4315167.1407191370328--”。
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       在 System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
       在 System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       在 System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
       在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       在 Handler.SocialServiceReference.WebReviewService.GetCkxx(GetCkxx request)
       在 Handler.SocialServiceReference.WebReviewServiceClient.Handler.SocialServiceReference.WebReviewService.GetCkxx(GetCkxx request) 位置 E:\xxx
       在 Handler.SocialServiceReference.WebReviewServiceClient.GetCkxx(Int64 arg0, Int64 arg1) 位置 E:\xxx
       在 Handler.test.HelloWorld() 位置 E:\xxx

------解决方案--------------------
添加服务引用的时候,webservice的地址能不能正常打开,里面的方法能不能正确显示,或java的客户端能不能正常调用HelloWorld()
------解决方案--------------------
用java写个客户端看能不能正常调用HelloWorld()
------解决方案--------------------
服务端的问题,你在服务端的方法里加上try..catch捕获异常,或者把异常写到日志里面,然后看看是什么问题
------解决方案--------------------
1、text/xml与绑定text/xml; charset=utf-8的内容类型不匹配,看看webservice返回的content-type是什么
2、客户端是不是两多个配置文件
3、看看这篇博文http://www.cnblogs.com/jams742003/archive/2008/10/30/1322761.html
  相关解决方案