WCF:找不到服务器 - 从运行异步时的跟踪空消息但从控制台应用程序正常工作?

时间:2010-06-07 14:38:55

标签: wcf silverlight asynchronous silverlight-4.0

今天的脱发原因一直是以下情况:

我有一个服务,需要2个字符串并返回另一个字符串。此服务使用basicHttpBinding

<basicHttpBinding>
  <binding name="basicHttpNoSec">
    <security mode="None" />
  </binding>
</basicHttpBinding>

无论如何,它在控制台测试应用程序中运行良好。

我有一个位于顶部的silverlight应用程序,它实现了另一个basicHttpBinding服务,该服务只是在其他服务中重用该合同,而silverlight App使用此服务。

我有一个控制台应用程序,确认此服务正在运行并设置了basichttpbinding。

我已经准备好了所有clientAccessPolicy。

当我运行silverlight应用程序时,区别在于它运行所有异步...因此,我直接返回rom wcf的唯一消息是找不到服务器。

当我启用跟踪时,我深入研究这条消息 - 因为我知道方法有效并且我传入的参数将返回一个有效的字符串我真的很困惑,原因是什么。任何帮助非常感谢。

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
 <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
  <EventID>131075</EventID>
  <Type>3</Type>
  <SubType Name="Error">0</SubType>
  <Level>2</Level>
  <TimeCreated SystemTime="2010-06-07T14:17:40.6639249Z" />
  <Source Name="System.ServiceModel" />
  <Correlation ActivityID="{8ea9530e-12f4-4a82-9c26-dd2e23264c3c}" />
  <Execution ProcessName="aspnet_wp" ProcessID="4616" ThreadID="6" />
  <Channel />
  <Computer>5JC2Y2J</Computer>
</System>
<ApplicationData>
 <TraceData>
  <DataItem>
   <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
    <TraceIdentifier>http://msdn.microsoft.com/en-GB/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
    <Description>Throwing an exception.</Description>
    <AppDomain>/LM/w3svc/1/ROOT/CopSilverlight.Web-1-129203938565564172</AppDomain>
    <Exception>
     <ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
     <Message>There is a problem with the XML that was received from the network. See inner exception for more details.</Message>
     <StackTrace>
at System.ServiceModel.Channels.HttpRequestContext.CreateMessage()
at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
     </StackTrace>
     <ExceptionString>System.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details. ---&gt; System.Xml.XmlException: The body of the message cannot be read because it is empty.
   --- End of inner exception stack trace ---</ExceptionString>
     <InnerException>
      <ExceptionType>System.Xml.XmlException, System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
      <Message>The body of the message cannot be read because it is empty.</Message>
      <StackTrace>
at System.ServiceModel.Channels.HttpRequestContext.CreateMessage()
at System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
at System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult result)
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest()
at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.OnBeginRequest(Object state)
at System.Runtime.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
      </StackTrace>
      <ExceptionString>System.Xml.XmlException: The body of the message cannot be read because it is empty.</ExceptionString>
      </InnerException>
     </Exception>
    </TraceRecord>
   </DataItem>
  </TraceData>
 </ApplicationData>
</E2ETraceEvent>

作为参考,有效的consoel应用程序的绑定信息如下

<binding name="BasicHttpBinding_IManagement" closeTimeout="00:01:00"
         openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
         allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
         maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
         messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
         useDefaultWebProxy="true">
         <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                       maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
 </binding>

和破解的silverlight应用程序的绑定是

<binding name="BasicHttpBinding_IManagement" maxBufferSize="2147483647"
         maxReceivedMessageSize="2147483647">
         <security mode="None" />
</binding>

由svcutil从相同的wsdl生成。

1 个答案:

答案 0 :(得分:0)

结果发现服务中存在绑定问题,导致Silverlight应用程序使用非BasicHttpBinding。

真的很蠢。