Sunday, May 1, 2011

Always the first WCF call fails

I have a WCF service (svc) hosted in an asp.net application. After every restart of the IIS the first call to the WCF fails with the error:

System.ServiceModel.ProtocolException: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/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: '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>Title</title>
  <meta name="GENERATOR" content="Microsoft Visual Studio 7.0">
  <meta name="CODE_LANGUAGE" content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  <script language=javascript src="BaseScripts.aspx"></script>
  <LINK href="css.css" type=text/css rel=stylesheet>
  <style>.Txt { BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 100px; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-WIDTH: 0px }
 .TxtSelected { BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; WIDTH: 100px; BACKGROUND-COLOR: #ffffff; BORDER-RIGHT-WIDTH: 0px }
 .CreonLabel { PADDING-RIGHT: 2px; PADDING-LEFT: 2px; FONT-WEIGHT: normal; FONT-SIZE: 11px; PADDING-BOTTOM: 0px; COLOR: #b2d9ff; PADDING-TOP'.

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.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 ConsoleApplication1.ReportReference.IExperimentReportService.GetPDFOptions()
   at ConsoleApplication1.ReportReference.ExperimentReportServiceClient.GetPDFOptions() in D:\Tests\WebApplication1\ConsoleApplication1\Service References\ReportReference\Reference.cs:line 70
   at ConsoleApplication1.Program.Main(String[] args) in D:\Tests\WebApplication1\ConsoleApplication1\Program.cs:line 21

All the other calls to the WCF after the failed one are successfully. What can i do so that also the first call is successfully?

Source: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/43093077-40fe-4473-8f79-1ea2b9e71639

web services architecture modern architecture network security architecture new orleans architecture architecture tour chicago boat

No comments:

Post a Comment