开发者

Deploying WCF service and silverlight in SSL

I have an silverlight application with an SSL service. If i deploy the service without SSL all works right, but if i activate the SSL and change the endpoint from http://MyService to https://MyService in the servicereference.clientconfig, and change in web.config: endpoint from "basicHttpBinding" to "webHttpBinding" The service dont work and produce the next error:

Unhandled error in silverlight Application [Arg_NullReferenceException] 
Arguments: debbuging resource string ar unavalible

I dont know if something is wrong or i need to do something more... etc. Thanks in advance to everybody i ne开发者_JAVA百科ed help.


You can't convert the service endpoint to webHttpBinding because Silverlight only supports basicHttpBinding. To secure your services for Silverlight, you need create a basicHttpBinding with Transport level security. Then, create a service behavior that specifies that httpsGetEnabled="true". I have included a sample below:

Service Side Web.config

<bindings>
  <basicHttpBinding>
    <binding name="SecureBasicHttpBinding" 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="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

<services>
  <service name="MyService" behaviorConfiguration="SecureServiceBehavior">
    <endpoint address="" binding="basicHttpBinding" contract="IMyService" bindingConfiguration="SecureBasicHttpBinding" />
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="SecureServiceBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Client Side

In the client config, add the same SecureBasicHttpBinding from the services and then add the following endpoint attribute:

bindingConfiguration="SecureBasicHttpBinding"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜