2011-02-16 2 views
3

WCF 클라이언트를 사용하여 비 -WCF SOAP 1.2 웹 서비스를 사용하고 있습니다. 아래 그림과 같이 SOAP 오류가 발생하면 FaultException 대신 ProtocolException을 수신합니다. 통신 바인딩에 문제가 없으며 요청이 성공적으로 처리되고 있습니다. 하지만 내 WCF 클라이언트 오류 오류를 액세스 할 수 없습니다. 어떤 아이디어?WCF 클라이언트가 FaultException으로 SOAP Fault를받지 못하는 이유는 무엇입니까?

<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 또는 데이터 샘플을 게시하는 경우 텍스트 편집기에서 해당 행을 강조 표시하고 편집기 툴바에서 "코드 샘플"버튼 ('{}) '을 클릭하여 멋지게 형식을 지정하고 구문 강조 표시하십시오 그것! –

+0

ProtocolException의 스택 추적을 게시 하시겠습니까? –

+0

원본 질문에 스택 추적을 추가했습니다. 감사. – samfisher007

답변

0

나는 원시 응답을 가로 챌 수 Fiddler를 사용하는 것이 좋습니다 것이라고합니다. 이러한 상황 (interop)은 WCF를 완전히 무시하고 응답 메시지를 "유선상"으로 읽는 것이 가장 좋습니다. WCF를 통한 비 -WCF 오류 또는 직렬화 오류를 디버깅하려고하면 두통이 생길 수 있습니다.)

종종 원시 응답을 보면 아픈 엄지 손가락처럼 문제를 지적합니다.

+0

귀하의 답변에 감사드립니다. 나는 원시 SOAP 응답을 가지고 있으며 그 원인을 알고있다. 그러나 WCF 클라이언트 내에서 오류 정보에 액세스 할 수 있는지에 관심이 있습니다. 현재 예외는 400 잘못된 요청을 나타내는 ProtocolException입니다. 나는 FaultException을 얻을 것이라고 예상했다. 그래서 내 질문에 왜 FaultException이 발생하지 않는 것입니까? – samfisher007

0

서버가 400 HTTP 응답 코드를 반환하기 때문에 문제가 있다고 생각합니다. 분명히 200이 아닌 응답 코드가있는 메시지 본문은 Silverlight 클라이언트에 액세스 할 수 없습니다.

서버를 제어 할 수있는 경우 400 응답 코드 대신 400 응답 코드를 보낼 수 있지만 서버를 제어 할 수없는 경우 클라이언트를 수정하여

대체 HTTP 스택을 사용하도록 클라이언트를 변경하려면 here 지침이 있습니다. 나는 당신과 같은 문제를 가지고 있었지만 (HTTP 응답 코드 500), 문제가 해결되었습니다.

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

가의 IsOneWay = 진정한 특성으로 표시된 호출되는 방법이다 : 당신이해야 할 모든합니다 (MainPage 클래스의 생성자에, 예를 들어)하여 Silverlight 응용 프로그램의 시작 부분에이 코드를 추가입니다 생성 된 프록시 클래스?

그렇다면 SOAP 오류가 수신 될 백 채널이 없지만 WCF가 다른 방식으로 다시 가져올 수 있으며 이것이 ProtocolException로 표시됩니다. 내가 아는 한 IsOneWay = false가 있어야 SOAP 오류가 발생합니다.

관련 문제