Configuration to Enable HTTPS WCF Web Service on an Azure Web Role -


i’ve searched through several posts (here , here, example) related area, none seem address straight forward scenario question: binding configurations should used configure ssl enabled (e.g. https) wcf web service on azure web role: in web role’s servicedefinition.csdef, web service’s web.config , client’s app.config?

i have configured ssl cert service in azure portal , in web role’s serviceconfiguration.csfg https:// myapp.cloudapp.net , appears working fine.

when browse service https:// myapp.cloudapp.net/wcfservice.svc?wsdl , metadata displays correctly. can add service reference service client, when call it, exception: “there no endpoint listening @ https:// myapp.cloudapp.net/wcfservice.svc accept message. caused incorrect address or soap action. see innerexception, if present, more details.” inner exception: “the remote server returned error: (404) not found”

the respective configuration files this: servicedefinition.csdef :

<webrole name="wcfservicewebrole" vmsize="small">     <sites>       <site name="web">         <bindings>           <binding name="httpin" endpointname="httpin" />           <binding name="httpsin" endpointname="httpsin" />         </bindings>       </site>     </sites>     <endpoints>       <inputendpoint name="httpin" protocol="http" port="8080" />       <inputendpoint name="httpsin" protocol="https" port="443" certificate="mysslcert" />     </endpoints>     <certificates>       <certificate name="mysslcert" storelocation="localmachine" storename="my" />     </certificates>   </webrole> 

web service’s web.config :

<system.servicemodel>     <behaviors>       <servicebehaviors>         <behavior>                         <servicemetadata httpgetenabled="true" httpsgetenabled="true"/>           <servicedebug includeexceptiondetailinfaults="true"/>         </behavior>       </servicebehaviors>     </behaviors>     <servicehostingenvironment multiplesitebindingsenabled="true" />     <bindings>       <basichttpbinding>         <binding name="basichttpbinding" />           <security mode="transport">             <transport clientcredentialtype="none" />           </security>         </binding>       </basichttpbinding>     </bindings>   </system.servicemodel> 

the client’s app.config looks this:

<system.servicemodel>         <bindings>             <basichttpbinding>                 <binding name="basichttpbinding_imywebservice" >                  <security mode="transport">                     <transport clientcredentialtype="none" />                  </security>              </binding>             </basichttpbinding>         </bindings>         <client>             <endpoint address="https://myapp.cloudapp.net/mywebservice.svc"                 binding="basichttpbinding" bindingconfiguration="basichttpbinding_imywebservice"                 contract="mywebserviceservicereference.imywebservice"                 name="basichttpbinding_imywebservice" />         </client>     </system.servicemodel> 

when use svcutil generate binding configuration client, generates:

<system.servicemodel>         <bindings>             <basichttpbinding>                 <binding name="basichttpbinding_imywebservice" 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="none">                         <transport clientcredentialtype="none" proxycredentialtype="none"                             realm="" />                         <message clientcredentialtype="username" algorithmsuite="default" />                     </security>                 </binding>             </basichttpbinding>         </bindings>         <client>             <endpoint address="https://myapp.cloudapp.net/mywebservice.svc"                 binding="basichttpbinding" bindingconfiguration="basichttpbinding_imywebservice"                 contract="mywebserviceservicereference.imywebservice" name="basichttpbinding_imywebservice" />         </client>     </system.servicemodel> 

which gives exception when call web service: "the provided uri scheme 'https' invalid; expected 'http'." doesn't seem correct configuration either.

i’m sure matter of getting right configuration in 3 files above, can’t seem find correct combination anywhere, , appreciate if call out should be. conor.

an azure dev helped me figure out answer this, problem omission of service node web service's web.config file. here full set of configuration files required scenario in case helps else trying achieve same result (an ssl/https wcf web service implemented on azure web role:

servicedefinition.csdef :

<webrole name="wcfservicewebrole" vmsize="small">     <sites>       <site name="web">         <bindings>           <binding name="httpin" endpointname="httpin" />           <binding name="httpsin" endpointname="httpsin" />         </bindings>       </site>     </sites>     <endpoints>       <inputendpoint name="httpin" protocol="http" port="8080" />       <inputendpoint name="httpsin" protocol="https" port="443" certificate="mysslcert" />     </endpoints>     <certificates>       <certificate name="mysslcert" storelocation="localmachine" storename="my" />     </certificates>   </webrole> 

web service’s web.config :

<system.servicemodel>     <behaviors>       <servicebehaviors>         <behavior>                         <servicemetadata httpgetenabled="true" httpsgetenabled="true"/>           <servicedebug includeexceptiondetailinfaults="true"/>         </behavior>       </servicebehaviors>     </behaviors>     <servicehostingenvironment multiplesitebindingsenabled="true" />     <bindings>       <basichttpbinding>         <binding name="basichttpbinding" />           <security mode="transport">             <transport clientcredentialtype="none" />           </security>         </binding>       </basichttpbinding>     </bindings>     <services>       <service behaviorconfiguration="" name="mywebservicenamespace.mywebservice">       <endpoint bindingconfiguration="basichttpbinding" address="" binding="basichttpbinding"     contract="mywebservicenamespace.imywebservice" />       <endpoint address="mex" binding="mexhttpsbinding" contract="imetadataexchange" />      </service>    </services>   </system.servicemodel> 

the client’s app.config looks this:

<system.servicemodel>         <bindings>             <basichttpbinding>                 <binding name="basichttpbinding_imywebservice" >                  <security mode="transport">                     <transport clientcredentialtype="none" />                  </security>              </binding>             </basichttpbinding>         </bindings>         <client>             <endpoint address="https://myapp.cloudapp.net/mywebservice.svc"                 binding="basichttpbinding" bindingconfiguration="basichttpbinding_imywebservice"                 contract="mywebserviceservicereference.imywebservice"                 name="basichttpbinding_imywebservice" />         </client>     </system.servicemodel> 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -