Skip to main content

Microsoft Silverlight

Answered Question WCF Service and https problem in silverlightRSS Feed

(0)

Navnee
Navnee

Member

Member

3 points

10 Posts

WCF Service and https problem in silverlight

 Hi,

I am facing problems in consuming secure  WCF service in  Silverlight application, the WCF Service is running fine  on http:// however if i try to consume it using https:// URI then it throws error.

 

  

  <client />
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding">
        </binding>
        <binding name="basicHttpsBinding">
          <security mode="Transport">
            <transport clientCredentialType ="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

 <behaviors>
      <serviceBehaviors>
        <behavior name="SessionServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"   />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
        <behavior name="AnnualizedRateOfReturnBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
</behaviors>
 <services>
      <service behaviorConfiguration="SessionServiceBehavior" name="SessionService">
        <endpoint address="" binding="basicHttpBinding"   contract="SessionService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="AnnualizedRateOfReturnBehavior" name="AnnualizedRateOfReturn">
        <endpoint address=""  binding="basicHttpBinding"   contract="AnnualizedRateOfReturn" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
      
    </services>

 here is the C# code

  

var WebService = new ServiceRef.SessionServiceClient("BasicHttpBinding_SessionService", Address.AbsoluteUri);
  
WebService.ReturnSessionClassCompleted += new EventHandler(WebService_ReturnSessionClassCompleted);
               
 

However the if i run WCF service from Directly in browser. Both with http:// and https:// are running fine. means problem is in just consuming WCF service in Silverlight

 

Sergey.Lutay
Sergey.L...

Contributor

Contributor

7256 points

1,354 Posts

Re: WCF Service and https problem in silverlight

Hi,

Do you pu a clientaccesspolicy.xml file to domain of WCF service. There are cross domain request from Silverlight application (http) to WCF service (https).Look Network Security Access Restrictions in Silverlight

(If this has answered your question, please click on "mark as answer" on this post. Thank you!)

Blog

Twitter

Sincerely,
Sergey Lutay

Navnee
Navnee

Member

Member

3 points

10 Posts

Re: WCF Service and https problem in silverlight

This is My ClientAccessPolicy.xml


<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="*"/>
        <domain uri="http://*"/>
          <domain uri="https://*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>
 

Sergey.Lutay
Sergey.L...

Contributor

Contributor

7256 points

1,354 Posts

Re: WCF Service and https problem in silverlight

Try this:

 

<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="*">
        <domain uri="http://*"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>
 

(If this has answered your question, please click on "mark as answer" on this post. Thank you!)

Blog

Twitter

Sincerely,
Sergey Lutay

Navnee
Navnee

Member

Member

3 points

10 Posts

Re: WCF Service and https problem in silverlight

Again Same problem, Silverlight application is working fine if i use http:// , its giving problem in https://

Sergey.Lutay
Sergey.L...

Contributor

Contributor

7256 points

1,354 Posts

Re: WCF Service and https problem in silverlight

Look with Fiddler tool at primary information about error.

Remark: it is not sniff requests over localhost

(If this has answered your question, please click on "mark as answer" on this post. Thank you!)

Blog

Twitter

Sincerely,
Sergey Lutay

Navnee
Navnee

Member

Member

3 points

10 Posts

Re: Re: WCF Service and https problem in silverlight

 It is showing Not Found error.

msalsbery
msalsbery

Contributor

Contributor

2056 points

379 Posts

Re: WCF Service and https problem in silverlight

Navnee:
if i try to consume it using https:// URI then it throws error.
 


I may be missing something, but I don't see where any of your endpoints are using the binding configured with transport security.

 

Are you missing a "bindingConfiguration="basicHttpsBinding"" on at least one of your endpoints?
 

Mark Salsbery
Microsoft MVP - Visual C++

Jonathan Shen – MSFT
Jonathan...

All-Star

All-Star

24979 points

2,435 Posts

Microsoft
Answered Question

Re: WCF Service and https problem in silverlight

Hi Navnee,

Please check Varshavmane's reply on your another post. Since this is a duplicate thread, we will mark it as "Resolved".

Best regards,

Jonathan

Jonathan Shen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities