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
Post a Comment