具有自定义绑定的Silverlight WCF安全性

时间:2011-03-25 10:14:58

标签: silverlight wcf windows-authentication custom-binding

我有一个Silverlight应用程序,可以调用许多WCF服务。银光客户端的典型绑定如下所示:

<basicHttpBinding>
    <binding name="ClientBindingName" maxBufferSize="2147483647"
        maxReceivedMessageSize="2147483647">
        <security mode="TransportCredentialOnly" />
    </binding>
</basicHttpBinding>

并且它与服务器绑定配对如下:

<basicHttpBinding>
    <binding name="ServerbindingName" sendTimeout="00:02:00">
        <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows"/>
        </security>                    
    </binding>
</basicHttpBinding>

对于其中一项服务,我需要自定义绑定,但我无法找到不会导致403错误的绑定组合。

我能为客户提供的最好的是:

<customBinding>
    <binding name="CustomBinding_IZipService_StreamedResponse" closeTimeout="00:10:00"
             openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
        <binaryMessageEncoding />
        <httpTransport maxReceivedMessageSize="2147483647"
                       maxBufferSize="2147483647"
                       transferMode="StreamedResponse" />
    </binding>
</customBinding>

和服务:

<customBinding>
    <binding name="FS.SUV.Services.ZipService.customBinding"
             receiveTimeout="00:10:00" sendTimeout="00:10:00">
      <binaryMessageEncoding>
        <readerQuotas maxStringContentLength="524288000"/>
      </binaryMessageEncoding>
      <httpTransport transferMode="StreamedResponse"
                     maxBufferSize="524288000"
                     maxBufferPoolSize="524288000"
                     maxReceivedMessageSize="524288000" />
      <security authenticationMode="SecureConversation" requireSecurityContextCancellation="true">
        <secureConversationBootstrap authenticationMode="UserNameOverTransport" />
      </security>
    </binding>
  </customBinding>

如何通过windows身份验证获得自定义绑定以使用Silverlight?

2 个答案:

答案 0 :(得分:2)

事实证明我试图过于复杂。客户端绑定很好,因此保留为:

<binding name="CustomBinding_IZipService_StreamedResponse" closeTimeout="00:10:00"
         openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
    <binaryMessageEncoding />
    <httpTransport maxReceivedMessageSize="2147483647"
                   maxBufferSize="2147483647"
                   transferMode="StreamedResponse" />
</binding>

,服务器绑定需要像这样设置:

<customBinding>
    <binding name="ClientBindingName"
             receiveTimeout="00:10:00" sendTimeout="00:10:00">
        <binaryMessageEncoding>
            <readerQuotas maxStringContentLength="524288000"/>
        </binaryMessageEncoding>
        <httpTransport transferMode="StreamedResponse"
                       maxBufferSize="524288000"
                       maxBufferPoolSize="524288000"
                       maxReceivedMessageSize="524288000"
                       authenticationScheme="Negotiate" />
    </binding>
</customBinding>

我设法通过使用这一代工具来获得绑定:http://webservices20.cloudapp.net/default.aspx

答案 1 :(得分:1)

您的配置不正确。双方尝试这一点(并根据需要修改阅读器配额和邮件大小限制):

<customBinding>
    <binding name="CustomBinding_IZipService_StreamedResponse" closeTimeout="00:10:00"
             openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
        <binaryMessageEncoding />
        <httpTransport authenticationMode="Negotiate"
                       maxReceivedMessageSize="2147483647"
                       maxBufferSize="2147483647"
                       transferMode="StreamedResponse" />
    </binding>
</customBinding>