2012-02-16 22 views
2

最近我一直在wcf服务调用中遇到问题,在邮件的开始处一次随机地在邮件中返回邮件头两次,并在邮件的末尾一次。下面是我通过小提琴手看到的一个例子:WCF标题在邮件中重复

HTTP/1.1 200 OK 
Cache-Control: private 
Content-Type: text/xml; charset=utf-8 
Vary: Accept-Encoding 
Server: Microsoft-IIS/7.5 
X-AspNet-Version: 4.0.30319 
X-Powered-By: ASP.NET 
Date: Thu, 16 Feb 2012 15:48:22 GMT 
Content-Length: 308 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><Person_UpdateLastCSIDResponse/></s:Body></s:Envelope>HTTP/1.1 200 OK 
Cache-Control: private 
Content-Length: 126 
Content-Type: text/xml; charset=utf-8 
Server: Microsoft-IIS/7.5 
X-AspNet-Version: 4.0.30319 
X-Powered-By: ASP.NET 

这并非总是发生,而是似乎是随机发生的。这不是只发生一次特定的服务呼叫,而是可以在任何呼叫下发生。我还没有能够确定一个模式。

我们通过silverlight应用程序中的负载平衡器使用绑定类型basicHttpBinding。

编辑:

我们有一个很基本的配置:

服务端:

<system.serviceModel> 
<extensions> 
    <behaviorExtensions> 
    <add name="silverlightFaults" type="Website.Support.SilverlightFaultBehavior, Website" /> 
    </behaviorExtensions> 
</extensions> 
<behaviors> 
    <serviceBehaviors> 
    <behavior> 
    <serviceMetadata httpGetEnabled="true" /> 
    <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
    multipleSiteBindingsEnabled="true" /> 
<services> 
    <service name="Website.Services.CommonService"> 
    <endpoint address="" behaviorConfiguration="SilverlightFaultBehavior" 
    binding="basicHttpBinding" bindingConfiguration="MyDefaultBinding" 
    contract="Website.Services.CommonService" /> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
<bindings> 
    <basicHttpBinding> 
    <binding name="MyDefaultBinding" maxBufferSize="6500000" maxReceivedMessageSize="6500000"> 
    <readerQuotas maxDepth="32" maxStringContentLength="52428800" maxArrayLength="52428800" 
     maxBytesPerRead="4096" maxNameTableCharCount="52428800" /> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<client /> 
</system.serviceModel> 

客户端:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="SecureBinding" maxBufferSize="8388608" maxReceivedMessageSize="8388608"> 
       <security mode="Transport" /> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 

    <client> 
     <endpoint address="https://Website/Services/CommonService.svc" binding="basicHttpBinding" bindingConfiguration="SecureBinding" 
      contract="CommonSvcReference.CommonService" name="BasicHttpBinding_CommonService"/> 
    </client> 
</system.serviceModel> 
+0

上使用了示例代码您可以提供服务配置吗? (' ... ...'部分) – 2012-02-16 17:27:27

回答

1

我相信我终于解决了我的问题。由于我们使用的是负载平衡器,因此您需要保持活跃状态​​为假。问题是BasicHttpBinding保持活着为真。切换到customBinding允许您关闭保持活动并解决了问题。

由于将保持活动状态设置为false的扩展会导致应用程序变慢。为了解决这个问题,我在http://blog.tonysneed.com/2012/06/18/building-scalable-and-secure-wcf-services/