none
Problem using https in WCF to comunicate with silverlight 3....need help...

    Question

  • Hi,

    I have four WCF services and one cross-domain policy hosted in one Windows Service....all these are working with http....but not working with https :( I do have SSL certificate on my computer.....

    Here is my App.Config file....what's going wrong??? please help....thanks in advance....

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.web>
        <compilation debug="true" />
      </system.web>
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <services>
          <service behaviorConfiguration="SL_Secure_WCF.ServiceBehavior"
            name="SL_Secure_WCF.NoAuthentication">
            <endpoint address="" binding="customBinding"
                      bindingConfiguration="binaryHttpBinding"
                      contract="SL_Secure_WCF.INoAuthentication">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="https://localhost:8731/MessageService/NoAuthentication" />
              </baseAddresses>
            </host>
          </service>

          <service behaviorConfiguration="SL_Secure_WCF.ServiceBehavior"
            name="SL_Secure_WCF.MessageHeaderAuthentication">
            <endpoint address="" binding="customBinding"
                      bindingConfiguration="binaryHttpBinding"
                      contract="SL_Secure_WCF.IMessageHeaderAuthentication">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="https://localhost:8731/MessageService/MessageHeaderAuthentication" />
              </baseAddresses>
            </host>
          </service>

          <service behaviorConfiguration="SL_Secure_WCF.ServiceBehavior"
            name="SL_Secure_WCF.MessageHeaderOperationBehaviourAuthentication">
            <endpoint address="" binding="customBinding"
                      bindingConfiguration="binaryHttpBinding"
                      contract="SL_Secure_WCF.IMessageHeaderOperationBehaviourAuthentication">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="https://localhost:8731/MessageService/MessageHeaderOperationBehaviourAuthentication" />
              </baseAddresses>
            </host>
          </service>

          <service behaviorConfiguration="SL_Secure_WCF.ServiceBehavior"
              name="SL_Secure_WCF.MethodParameterAuthentication">
            <endpoint address="" binding="customBinding"
                      bindingConfiguration="binaryHttpBinding"
                      contract="SL_Secure_WCF.IMethodParameterAuthentication">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="https://localhost:8731/MessageService/MethodParameterAuthentication" />
              </baseAddresses>
            </host>
          </service>
         
          <service name="SL_Secure_WCF.CrossDomainService">
            <endpoint address="" behaviorConfiguration="SL_Secure_WCF.CrossDomainServiceBehavior"
                      binding="webHttpBinding"
                      contract="SL_Secure_WCF.ICrossDomainService" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8731/" />
              </baseAddresses>
            </host>
          </service>
        </services>

        <bindings>
          <customBinding>
            <binding name ="binaryHttpBinding">
              <binaryMessageEncoding/>
              <!--<httpTransport/>-->
              <httpsTransport authenticationScheme="Anonymous"/>
            </binding>
          </customBinding>
        </bindings>
       
        <behaviors>
          <serviceBehaviors>
            <behavior name="SL_Secure_WCF.ServiceBehavior">
              <!--<serviceMetadata httpGetEnabled="True"/>-->
              <serviceMetadata httpsGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
          <endpointBehaviors>
            <behavior name="SL_Secure_WCF.CrossDomainServiceBehavior">
              <webHttp />
            </behavior>
          </endpointBehaviors>
        </behaviors>
      </system.serviceModel>
    </configuration>

    Monday, November 16, 2009 1:41 PM

All replies

  • Stupid question...does your clientaccesspolicy.xml file allow the https protocol?

    http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx

     

    Tuesday, November 17, 2009 1:20 AM
  •  no question is stupid....thanks for the reply....yes it does....

    here is my clientaccesspolicy.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <access-policy>
      <cross-domain-access>
        <policy>
          <allow-from http-request-headers="*">
            <domain uri="http://*"/>
            <domain uri="https://*"/>
          </allow-from>
          <grant-to>
            <resource path="/" include-subpaths="true"/>
          </grant-to>
        </policy>
      </cross-domain-access>
    </access-policy>

     

    do you know any good samples? I'm really stuck in this task....thanks in advance.

    kate

    Tuesday, November 17, 2009 11:55 AM
  • I have the same problem and can't seem to find a good answer. It is related to the fact that the silverlight app runs in http and the services on https. So if you run the app in https all is fine.

    But I want it to run on http, so on I go... Where is that solution?

    Friday, January 22, 2010 5:49 AM
  •  I'm also facing right now the same problem, can't get my wcf service run under https and call it from sl3.

    If you found a solution, can you please post it here, I would really appreciate it!

    Sunday, January 24, 2010 6:45 AM
  • It is related to the fact that the silverlight app runs in http and the services on https. So if you run the app in https all is fine.
     

     

    Cross scheme calls are allowed as long as the clientaccesspolicy.xml file policy allows it.

    What problem are you having?

     

    Sunday, January 24, 2010 5:12 PM
  • I followed guidance found on MSDN around the clientaccesspolicy and this is what it looks like for now.

    <access-policy>

    <cross-domain-access>

    <policy>

    <allow-from http-request-headers="*">

    <domain uri="https://*"/>

    <domain uri="http://*"/>

    </allow-from>

    <grant-to>

    <resource path="/" include-subpaths="true"/>

    </grant-to>

    </policy> </cross-domain-access>

    </access-policy>

     According to MSDN that should work, but it doesn't if the SL3 app is in http and the service on https. I get an cross-domain error.

    Monday, January 25, 2010 3:24 AM
  •  I had the same problem, here is my solution:

    http://forums.silverlight.net/forums/p/157100/353640.aspx#353640

    Monday, January 25, 2010 10:37 AM
  • According to MSDN that should work, but it doesn't if the SL3 app is in http and the service on https. I get an cross-domain error.

     

    Is the file named "clientaccesspolicy.xml" and located in the proper directory so it's available through a web request to the root of the domain?

    You should be able to browse t the domain root (http://yourdomain/clientaccesspolicy.xml) and get the XML in a browser.

    Monday, January 25, 2010 1:33 PM
  • Having problems with HTTPS and Silverlight with a web service as well... can't seem to get it working...

     My clientaccesspolicy.xml is:

    <?xml version="1.0" encoding="utf-8"?>
      <access-policy>
        <cross-domain-access>
          <policy>
            <allow-from http-request-headers="*">
              <domain uri="http://*"/>
              <domain uri="https://*"/>
            </allow-from>
            <grant-to>
              <resource path="/" include-subpaths="true"/>
            </grant-to>
         </policy>
        </cross-domain-access>
      </access-policy>

    my webconfig service model section is:

     <system.serviceModel>
      <behaviors>
       <serviceBehaviors>
        <behavior name="Kiosk.Web.DatabaseServiceBehavior">
         <serviceMetadata httpsGetEnabled="true" />
         <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
       </serviceBehaviors>
      </behaviors>
      <bindings>
       <customBinding>
        <binding name="customBinding1">
         <binaryMessageEncoding />
         <httpsTransport />
        </binding>
       </customBinding>
      </bindings>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
      <services>
       <service behaviorConfiguration="Kiosk.Web.DatabaseServiceBehavior"
        name="Kiosk.Web.DatabaseService">
        <endpoint address="" binding="customBinding" bindingConfiguration="customBinding1"
         contract="Kiosk.Web.DatabaseService" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
       </service>
      </services>
     </system.serviceModel>

    And my ServiceReferences.clientconfig is:

    <configuration>
        <system.serviceModel>
            <bindings>
                <customBinding>
                    <binding name="CustomBinding_DatabaseService">
                        <binaryMessageEncoding />
                        <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                    </binding>
                </customBinding>
            </bindings>
            <client>
                <endpoint address="https://myhealthriskonline.com/DatabaseService.svc"
                    binding="customBinding" bindingConfiguration="CustomBinding_DatabaseService"
                    contract="ServiceReference.DatabaseService" name="CustomBinding_DatabaseService" />
            </client>
        </system.serviceModel>
    </configuration>

    The site is allows http and https but all https requests are sent to https.  My service is DatabaseService.svc and is located in the root. I can get to it with a URL in my browser (GET method) but when Silverlight tries to get it using POST, I get a 404 not found...  any thoughts out there?  I've been scouring all forums and posts for a week now and just can't get it working... Thx for any help! Sherwood

    Monday, January 25, 2010 2:34 PM
  • When moving from http to https you need to ensure that the client is set with

    "binding.Security.Mode = BasicHttpSecurityMode.Transport;" in silverlight before invoking the WCF service client.

     Also I believe you have done necessary web.config changes in the service side.

    Once both these are done, your https should work without any issue.

     

     

    Tuesday, January 26, 2010 10:14 PM
  • hi

    please go throught this post.

    http://forums.silverlight.net/forums/t/13275.aspx

    it may help u.

    Regards

    balu

    Thursday, January 28, 2010 12:58 AM