我准备将应用程序移植到silverlight。到目前为止,我的客户端应用程序使用netTcpBinding与服务器通信。然而,Silverlight不支持这一点,我发现他们建议使用自定义绑定。
我想知道我是否需要以特殊方式配置有关安全性的绑定。当客户端和服务器在同一台机器上运行时,我的分布式应用程序运行良好,但在不同运行时运行时则不行。在这种情况下,我收到以下错误:
带有操作的消息 'http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence' 不能在接收器处理, 由于ContractFilter不匹配 EndpointDispatcher。这可能是 因为合同不匹配 (发送者和发送者之间不匹配的行为) 接收者)或绑定/安全 发件人和发件人之间不匹配 revceiver。检查发件人和 接收者有相同的合同和 相同的绑定(包括安全性 要求,例如消息,运输, 无)。
我已经检查了合同和绑定(当切换到自定义绑定时,问题出现了,当它与netTcpBinding一起正常工作时)。该端口也在防火墙处启用。根据错误消息,我认为WCF可能会假设某些安全默认值在客户端和服务器中不匹配。
服务器配置文件如下:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="MetaEnabledBehavior" name="MyService">
<host>
<baseAddresses>
<add baseAddress="http://MyIP:Port#/MyService"/>
</baseAddresses>
</host>
<endpoint address="custom"
binding="customBinding"
contract="MyService"
bindingConfiguration="binaryHttpBinding"
/>
</service>
</services>
<bindings>
<customBinding>
<binding name="binaryHttpBinding">
<binaryMessageEncoding />
<reliableSession ordered="true" inactivityTimeout="01:00:00"/>
<httpTransport />
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MetaEnabledBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
客户端配置如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="default_binding">
<reliableSession ordered ="true" inactivityTimeout="01:00:00"/>
<binaryMessageEncoding maxReadPoolSize="64"
maxWritePoolSize="16"
maxSessionSize="2048">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binaryMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://MyIP:Port#/MyService/custom"
binding ="customBinding"
contract="MyService"
bindingConfiguration = "default_binding"
name="default_binding" />
</client>
</system.serviceModel>
</configuration>