2011-02-16 24 views
3

我正在使用WCF客户端来使用非WCF SOAP 1.2 Web服务。当收到如下所示的SOAP错误时,我收到ProtocolException而不是FaultException。通信绑定没有问题,请求正在成功处理。但我无法访问我的WCF客户端中的错误。有任何想法吗?为什么WCF客户端没有将Fault Fault作为FaultException接收?

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:wsr="http://docs.oasis-open.org/wsrf/r-2" xmlns:xmime5="http://www.w3.org/2005/05/xmlmime" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:ns10="http://www.onvif.org/ver10/events/wsdl/PausableSubscriptionManagerBinding" xmlns:ns3="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:ns4="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:ns5="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:ns6="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:ns7="http://www.onvif.org/ver10/events/wsdl/NotificationConsumerBinding" xmlns:ns8="http://www.onvif.org/ver10/events/wsdl/PullPointBinding" xmlns:ns9="http://www.onvif.org/ver10/events/wsdl/CreatePullPointBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:ter="http://www.onvif.org/ver10/error" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl"> 
    <SOAP-ENV:Header/> 
    <SOAP-ENV:Body> 
     <SOAP-ENV:Fault> 
     <SOAP-ENV:Code> 
      <SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value> 
      <SOAP-ENV:Subcode> 
       <SOAP-ENV:Value>ter:InvalidArgVal</SOAP-ENV:Value> 
       <SOAP-ENV:Subcode> 
        <SOAP-ENV:Value>ter:NoSource</SOAP-ENV:Value> 
       </SOAP-ENV:Subcode> 
      </SOAP-ENV:Subcode> 
     </SOAP-ENV:Code> 
     <SOAP-ENV:Reason> 
      <SOAP-ENV:Text xml:lang="en">Not exist</SOAP-ENV:Text> 
     </SOAP-ENV:Reason> 
     <SOAP-ENV:Detail> 
      <SOAP-ENV:Text xml:lang="en">The requested VideoSource does not exist.</SOAP-ENV:Text> 
     </SOAP-ENV:Detail> 
     </SOAP-ENV:Fault> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

System.ServiceModel.ProtocolException

“远程服务器返回一个意外的响应:(400)错误的请求

StackTrace 
    "Server stack trace: 
    at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding) 
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) 
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

    Exception rethrown at [0]: 
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
    at OnvifProxy.ImagingPort.SetImagingSettings(String VideoSourceToken, ImagingSettings20 ImagingSettings, Boolean ForcePersistence) 
    at OnvifProxy.ImagingPortClient.SetImagingSettings(String VideoSourceToken, ImagingSettings20 ImagingSettings, Boolean ForcePersistence) in D:\..\Proxies\OvifServices.cs:line 19005 
    at Integral.Common.IPCameras.ONVIF.Services.ImagingService.SetImageSettings(String pVideoSourceToken, ImagingSettings20 pImageSettings) in D:\..\Services\ImagingService.cs:line 375" string 
+0

如果您发布代码,XML或数据样本,请**在文本编辑器中突出显示这些行,然后单击编辑器工具栏上的“代码示例”按钮(“{}”)以精确地设置格式和语法突出显示它! – 2011-02-17 05:48:56

+0

请问您可以发布ProtocolException的堆栈跟踪吗? – 2011-02-17 10:04:17

回答

0

我建议使用Fiddler拦截原始响应在。在这些情况下(互操作性),最好是完全绕过WCF,并在它“到达网络上”时读取响应消息。尝试通过WCF调试非WCF故障或反序列化错误只会让您头痛。=)

大多数情况下,查看原始响应会将问题指向拇指痛处。

0

我认为你遇到的问题是因为服务器返回400 HTTP响应代码。显然,Silverlight客户端无法访问200以外响应代码的消息体。

如果您控制了服务器,您可以修改它以发送200响应代码而不是400,但是如果您没有服务器控制权,则需要修改客户端以接受除以外的响应代码200.

我发现一些指令here将客户端改为使用替代HTTP协议栈。我遇到了同样的问题(但HTTP响应代码为500),并解决了这个问题。所有你需要做的就是在你的Silverlight应用程序的开头添加以下代码(例如,在构造函数MainPage类):

bool registerResult = WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp); 
0

是被称为标记中的IsOneWay = true属性的方法生成的代理类?

如果接收到的SOAP错误没有回传通道,但WCF可以用其他方式取回回来,这显示为ProtocolException。据我所知,你需要有IsOneWay = false来获得SOAP错误。