c# - WCF REST Service with Windows Authentication and SSL -


i have wcf rest service being consumed android, ios , asp.net web application. endpoint methods return json format use webhttpbinding. problems started when secured service activating windows authentication(disabled anonymous before that). when try add service reference asp.net web application receive following error:

the http request unauthorized client authentication scheme 'anonymous'. authentication header received server 'negotiate,ntlm'. remote server returned error: (401) unauthorized. 

when call endpoints in browser windows dialog being showed username , pass , works fine, when try add reference receive error. i'm using ssl , service has https address.

web.config wcf rest service:

<system.web> <compilation debug="true" targetframework="4.5" /> <httpruntime targetframework="4.5" executiontimeout="90"        maxrequestlength="20000" usefullyqualifiedredirecturl="false" requestlengthdiskthreshold="8192" />     <authentication mode="windows" /> </system.web> <system.servicemodel> <servicehostingenvironment aspnetcompatibilityenabled="true" /> <bindings>   <webhttpbinding>     <binding name="webhttpendpointbinding"   maxreceivedmessagesize="200000000" maxbufferpoolsize="200000000">       <readerquotas maxdepth="32" maxarraylength="2000000000"   maxstringcontentlength="2000000000" />       <security mode="transport">       <transport clientcredentialtype="windows"  />        </security>     </binding>   </webhttpbinding>   </bindings> <services>   <service name="restsrvservice.restsrvrestservice"   behaviorconfiguration="servicebehavior">     <endpoint address="" name="webhttpendpoint" binding="webhttpbinding"   bindingconfiguration="webhttpendpointbinding" behaviorconfiguration="web"   contract="restsrvservice.irestsrvrestservice">        </endpoint>   <endpoint address="mex" binding="mexhttpbinding"  contract="imetadataexchange"/>   </service> </services> <behaviors>   <servicebehaviors>     <behavior name="servicebehavior">       <servicemetadata httpgetenabled="true" httpsgetenabled="true" />      <serviceauthenticationmanager authenticationschemes="integratedwindowsauthentication" />       <servicedebug includeexceptiondetailinfaults="true" />     </behavior>   </servicebehaviors>   <endpointbehaviors>     <behavior name="web">       <endpointdiscovery enabled="true">       </endpointdiscovery>       <webhttp  />     </behavior>   </endpointbehaviors> </behaviors> </system.servicemodel> 

web.config web application:

    <system.webserver>       <modules runallmanagedmodulesforallrequests="true"></modules>     </system.webserver>     <system.servicemodel>     <bindings>      <webhttpbinding>        <binding name="webhttpendpointbinding" bypassproxyonlocal="true" usedefaultwebproxy="true" maxreceivedmessagesize="200000000" maxbufferpoolsize="200000000">          <readerquotas maxdepth="32" maxarraylength="2000000000" maxstringcontentlength="2000000000" />            <security mode="transport">              <transport clientcredentialtype="windows"></transport>            </security>        </binding>      </webhttpbinding>     </bindings>     <client>        <endpoint address="https://serviceaddress/restsrvrestservice.svc/"         binding="webhttpbinding" bindingconfiguration="webhttpendpointbinding"         contract="restsrvservice.irestsrvrestservice"  behaviorconfiguration="webendpoint" name="webhttpendpoint">         <identity>         </identity>       </endpoint>     </client>     <behaviors>       <endpointbehaviors>         <behavior name="webendpoint">           <webhttp />         </behavior>       </endpointbehaviors>     </behaviors>   </system.servicemodel> 


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -