我有以下服务器配置文件,带有tcp绑定和Windows身份验证:
<customBinding>
<binding name="NewBindingTcpSecure">
<security authenticationMode="SecureConversation">
<secureConversationBootstrap authenticationMode="SspiNegotiated" />
</security>
<binaryMessageEncoding maxSessionSize="1000000">
<readerQuotas maxDepth="64" maxStringContentLength="131072" maxArrayLength="16384"
maxBytesPerRead="16384" maxNameTableCharCount="16384" />
</binaryMessageEncoding>
<!--<windowsStreamSecurity protectionLevel="None" />-->
<tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
portSharingEnabled="true" />
</binding>
当我使用Windows应用程序消费时它可以工作。 但是当我使用silverlight 4消耗它时它不起作用。
我在Silverlight中的客户端绑定如下:
<bindings>
<customBinding>
<binding name="DefaultTcp">
<binaryMessageEncoding />
<tcpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:4502/HelloWcf/Service1.svc"
binding="customBinding" bindingConfiguration="DefaultTcp"
contract="ServiceReference1.IService1" name="DefaultTcp" />
</client>
我收到的错误是:
The message could not be processed. This is most likely because the action 'http://tempuri.org/IService1/GetData' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.
请你帮忙......
答案 0 :(得分:0)
您是否创建了跨域访问策略以允许tcp通信?
<?xml version="1.0" encoding ="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*"/>
</allow-from>
<grant-to>
<socket-resource port="4502-4506" protocol="tcp" />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
查看这篇文章: http://www.silverlightshow.net/items/WCF-NET.TCP-Protocol-in-Silverlight-4.aspx
答案 1 :(得分:0)
我知道这个帖子有点老了,但万一有人检查出来,值得回答 - Silverlight不支持带有安全性的TCP绑定,如下所示: http://msdn.microsoft.com/en-us/library/cc645026(v=vs.95).aspx