web services - The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Basic realm="" -


i trying access soap webservice (http) requires authentication.i using wcf consume service. getting error message "the http request unauthorized client authentication scheme 'basic'. authentication header received server 'basic realm="xxxxx"'."

however when tried send authentication headers along each request. i'm getting 401 errors when attempt web service.

any appreciated, thank you.

this code looks like:

 var mybinding = new basichttpbinding("examplebinding");     mybinding.security.mode = basichttpsecuritymode.transportcredentialonly;     mybinding.security.transport.clientcredentialtype = httpclientcredentialtype.basic;     mybinding.security.transport.proxycredentialtype = httpproxycredentialtype.basic;     endpointaddress ea = new endpointaddress("http://test.co.uk/webservices");      var serviceclient = new servicesclient(mybinding, ea);     serviceclient.clientcredentials.username.username = "username";     serviceclient.clientcredentials.username.password = "password";     httprequestmessageproperty httprequestproperty = new httprequestmessageproperty();      httprequestproperty.headers[httprequestheader.authorization] = "basic " +                   convert.tobase64string(encoding.ascii.getbytes(serviceclient.clientcredentials.username.username + ":" + serviceclient.clientcredentials.username.password));      httprequestproperty.headers[httprequestheader.proxyauthorization] =  "basic " +             convert.tobase64string(encoding.ascii.getbytes(serviceclient.clientcredentials.username.username + ":" + serviceclient.clientcredentials.username.password));      using (operationcontextscope scope = new operationcontextscope((iclientchannel)serviceclient.innerchannel))     {       operationcontext.current.outgoingmessageproperties[httprequestmessageproperty.name] =   httprequestproperty;        var response = serviceclient.departureboard(request);     }   web config -----------    <bindings>           <basichttpbinding>             <binding name="jpservicesbinding">               <security mode="transport">                 <transport clientcredentialtype="basic" proxycredentialtype="basic" realm=""></transport>                 <message clientcredentialtype="username"/>               </security>             </binding>           </basichttpbinding>         </bindings>         <client>           <endpoint address="http://test.co.uk/webservices"             binding="basichttpbinding" bindingconfiguration="examplebinding"             contract="realtimeplanner.jservices" name="test" />         </client> 


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -