2011-05-11 2 views
0

지금부터 완벽하게 작동하는 wsHttpBinding 서비스를 사용하고 있습니다. 내 WPF 응용 프로그램 (클라이언트)이 연결되어 15 초마다 서버에서 자동으로 정보를받습니다.WCF 이상한 서비스 동작

System.ServiceModel.ProtocolException: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<html> 
    <head> 
     <title> </title> 
     <script type="text/javascript"> 
     function bredir(d,u,r,v,c){var w,h,wd,hd,bi;var b=false;var p=false;var s=[[300,250,false],[250,250,false],[240,400,false],[336,280,false],[180,150,false],[468,60,false],[234,60,false],[88,31,false],[120,90,false],[120,60,false],[120,240,false],[125,125,false],[728,90,false],[160,600,false],[120,600,false],[300,600,false],[300,125,false],[530,300,false],[190,200,false],[470,250,false],[720,300,true],[500,350,true],[550,480,true]];if(typeof(window.innerHeight)=='number'){h=window.innerHeight;w=window.innerWidth;}else if(typeof(document.body.offsetHeight)=='number'){h=document.body.offsetHeight;w=document.body.offsetWidth;}for(var i=0;i<s.length;i++){bi=s[i];wd=Math.abs(w-bi[0]);hd=Math.abs(h-bi[1]);if(wd<=2&&hd<=2){b=true;p=bi[2];}}if(b||(w<100&&w!==0)||(h<100&&h!==0)){if(p&&self==parent){self.close();return;}return'/b'+'anner.php?w='+w+'&h='+h+'&d='+d+'&u='+u+'&r='+r+'&view='+v;}else{return c;}} 
     </script> 
    </head> 
    <body onLoad="window.l'. 

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.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode) 
    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.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.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

당신이이 문제를 해결하는 위치에 어떤 생각을 가지고겠습니까 :

나는 (어떤 날은 아무 문제, 가끔 거기) 내 클라이언트는 다음과 같은 예외를 수신 가끔 몰래 있지 않은거야?

감사합니다. Camille.

+0

왜 당신은 그 페이로드에서 그 HTML을 가지고 있는지 모르겠다. xml 페이로드를 인코딩 할 수 없는지 확인해보십시오. – Perpetualcoder

답변

0

이것은 보안 협상과 관련이있는 것으로 보입니다. 보안 컨텍스트가 캐싱 될 가능성이 있으므로 세션이 만료되면 보안 컨텍스트가 더 이상 유효하지 않지만 여전히 컨텍스트를 전달하려고 시도합니다. 이 내용을 확인하고 매번 연결을 종료해야 할 수도 있습니다.

그리고 재시도 루틴을 구현해야 할 수도 있습니다. (통신 예외를 잡기위한 클라이언트 코드와 현재 클라이언트 객체를 버리고 재시도와 같은 새로운 클라이언트 객체를 생성 할 때). 내 고객 중 하나에서이.

는 난이 도움이되기를 바랍니다.

건배, 바그너.

+0

안타깝게도 보안 세션을 유지하는 것이 중요합니다. 내 인증 방법 (및 라이센스 선택)을 잃어 버리지 않고 연결을 다시 만들 수 없습니다. – user658664

+0

연결을 다시 생성하면 ClientCredentials 개체를 캐시하고 새 클라이언트로 다시 전달할 수 있습니다. –

1

난 그 가끔 연결중인 서비스를 추측에 문제가하고 HTML 오류 페이지로 응답하고있다 404 페이지를 찾을 수 없거나 503 개의 서비스를 사용할 수 없거나 500 개의 내부 서버 오류 일 수 있습니다.

+0

좋습니다.하지만 어떻게 디버깅 할 수 있습니까? 나는 여기에 처음 1024 바이트로 제한되어있어 클라이언트 (WPF) 측에서 더 많은 것을 얻을 수 없다 ... – user658664

+0

내 대답의 지각에 대해 유감스럽게 생각한다. 나는 아마도 [Fiddler] (http://www.fiddler2.com/)와 같은 것을 사용하여 HTTP 요청과 응답을 스니핑하기 시작할 것이다. 응답에서 당신은 문제가있을 때 HTML 페이지를 보게 될 것입니다. Fiddler와 같은 도구는 응용 프로그램에 응답을 보내기 전에 응답을 조사하기 때문에 유용합니다. –