Skip to main content

Microsoft Silverlight

Consuming WCF Services Hosted in HTTPS EnvironmentRSS Feed

(0)

muradmohdzain
muradmoh...

Member

Member

40 points

5 Posts

Consuming WCF Services Hosted in HTTPS Environment

Hi Guys,

I need your help on this. I have a silverlight + WCF project. My WCF services hosted in HTTPS IIS server (example: https://XX.XX.XX.XX/MinisterServiceHost/MinisterProfileService.svc). When i put that url to my local browser its working fine. means that the service is running. The problem now is that when i try to Add Service Reference in my silverlight project. It throwing error saying something about metadata cannot be resolved.

here is my wcf configuration at the hosting server :-

<system.serviceModel>

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

<services>

<service name="Minister.SyndicationService.MinisterSyndicationService" behaviorConfiguration="MyServiceTypeBehaviors">

<endpoint address="MinisterSyndicationService" behaviorConfiguration="ProfileBehavior"

binding="webHttpBinding" bindingConfiguration="webBinding" contract="Minister.SyndicationService.IMinisterSyndicationService">

</endpoint>

</service>

<service name="Minister.SyndicationService.MinisterProfileService" behaviorConfiguration="MyServiceTypeBehaviors">

<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding"

contract="Minister.SyndicationService.IMinisterProfileService" behaviorConfiguration="ProfileBehavior">

</endpoint>

</service>

</services>

<bindings>

<webHttpBinding>

<binding name="webBinding">

<security mode="Transport">

<transport clientCredentialType="Certificate"/>

</security>

</binding>

</webHttpBinding>

</bindings>

<behaviors>

<serviceBehaviors>

<behavior name="MyServiceTypeBehaviors">

<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />

<serviceDebug includeExceptionDetailInFaults="false" />

</behavior>

</serviceBehaviors>

<endpointBehaviors>

<behavior name="ProfileBehavior">

<webHttp/>

</behavior>

<behavior name="Minister.SyndicationService.Behavior">

<webHttp/>

</behavior>

</endpointBehaviors>

</behaviors>

</system.serviceModel>

 First a Security Alert popup came in asking to proceed or not, after click OK, an error message displayed on my screen :-

There was an error downloading 'https://XX.XX.XX.XX/MinisterServiceHost/MinisterProfileService.svc'.
The request failed with HTTP status 403: Forbidden.
Metadata contains a reference that cannot be resolved: 'https://XX.XX.XX.XX/MinisterServiceHost/MinisterProfileService.svc'.
The HTTP request was forbidden with client authentication scheme 'Anonymous'.
The remote server returned an error: (403) Forbidden.
If the service is defined in the current solution, try building the solution and adding the service reference again. 

Any solution on this?

rajeshkumar.a@gmail.com
rajeshku...

Member

Member

168 points

51 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

Hi,

I believe Silverlight supports only "basicHttpBinding". Hope you can access HTTPS with the below declaration in the config file

 

<security mode="Transport" />

(Please click on "Mark As Answer", if this has answered your query. Thanks)

Regards,
Rajesh
(http://rajeshkumara.wordpress.com)

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

 Hi,

As mentioned by rajesh you need to change security mode.

You can check this link also for reference.

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

Apart from that there is video in msdn site for https acess you can search for that also.(I don't tremember url)

Mark as answer if this post answered your question.

Harsh Bardhan

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

I have the feeling you're also missing a mexHttpBinding url.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

muradmohdzain
muradmoh...

Member

Member

40 points

5 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

rajeshkumar.a@gmail.com:

Hi,

I believe Silverlight supports only "basicHttpBinding". Hope you can access HTTPS with the below declaration in the config file

 

<security mode="Transport" />
 

Yes it is. I know about that. But that one is for the client config. My case is for the server config. If I configure my service config file at the server using basicHttpBinding, it won't work at all. There is another error will throw. That config file works perfectly. But one problem is that i cannot use the mexBinding. Another error will throw. The error that i mentioned in my first post is when i try to create client proxy using visual studio project (Add Service Reference). Let say my config file is like that (first post), how do i want to put in my mexHttpsBinding for my service? I have tried to put the mexbinding things, but an error will throw saying something about HttpGetUrl bla bla bla ... If I use basicHttpBinding, an error will throw saying something about security mode 'None' not match with IIS "ssl, ssl negotiate, ssl bla bla bla ....

come on guys,  how difficult it is to configure wcf in https environment. Someone out there can solved this. I'm counting on you. :)

to be honest, that config file working fine. i can see the service in my browser.

muradmohdzain
muradmoh...

Member

Member

40 points

5 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

 

MarkMonster:
I have the feeling you're also missing a mexHttpBinding url.

i noticed about this. Actually i have tried to put the mex binding, but it won;t work at all. My service will throw error. thats why i take it out and suddenly magical thing happened that my service running perfectly. :)

since that my service run in https environment, i used mexHttpsBinding Big Smile

errazudin
errazudin

Member

Member

2 points

1 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

Hi, That 'magical' thing.. is it explainable here? Love to hear that.. if you don't mind :)

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

What's basically is the case is the following.

In the old days (WebServices) we didn't have to worry about metadata. We could simply use ServiceName.asmx for the service and ServiceName.asmx?wsdl for the metadata.

In the new day (WCF) we will have to worry about this metadat. This is because each different protocol you want the Service to run on needs to be added. The MetaDataExchange is also a different protocol. For Https this will be mexHttpsBinding.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

muradmohdzain
muradmoh...

Member

Member

40 points

5 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

 

MarkMonster:

What's basically is the case is the following.

In the old days (WebServices) we didn't have to worry about metadata. We could simply use ServiceName.asmx for the service and ServiceName.asmx?wsdl for the metadata.

In the new day (WCF) we will have to worry about this metadat. This is because each different protocol you want the Service to run on needs to be added. The MetaDataExchange is also a different protocol. For Https this will be mexHttpsBinding.

well, to test for another solution, i created ASMX web service, hosted it in the same https environment. Guess what? the same error triggered.

Frankly, everything works fine in HTTP environment. There must be a way how to solve this problem. I will not give up until i got the solution. Fight till the end of your blood. :)

muradmohdzain
muradmoh...

Member

Member

40 points

5 Posts

Re: Consuming WCF Services Hosted in HTTPS Environment

There's not much articles talking about wcf hosted in https environment. Most of success 'stories' talking about wcf in http. Well i guess that is quite simple for any deployment. Searching on the net not much returning a good results.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities