Last post Feb 25, 2016 01:23 PM by Abrakamadpa
Feb 24, 2016 03:01 PM|Abrakamadpa|LINK
I have to connect to a Webservice. My fist step was - as usual - to add a servicereference in VS. This worked well, everything OK. But as soon as I call the service, the webservice-server returns the error:
Basic authentication information not found in http header
Now, I'm a bit lost. I've integrated a few webservices until today (mostly running under .net), but this one seems to hard for me. Usually it's a matter of seconds to implement a client in ASP.Net. But I'm lost here.
Using fiddler, I realized, that no credentail-data has been passed over HTTP-Headers. So, I guess my client is not sending any information.
In my web.config I have the following binding:
<binding name="myBindingOfHorror" messageEncoding="Text" textEncoding="UTF-8" allowCookies="True" transferMode="Buffered">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
Now, is this correct and if not, how do I find the information to how to configure the binding? Or could it be something else?
I'm quite helpless and therefore open for any input!
Feb 24, 2016 06:10 PM|mgebhard|LINK
I believe the error is simply you have not send the appropriate credentials in the HTTP header. Basic Authentication has nothing to do with the SOAP message.
Feb 24, 2016 07:04 PM|Abrakamadpa|LINK
Thanks for your answer.
I'm not sure if I'm completely wrong, but I'm not making a HTTPRequest, I'm using the Webreference created in VisualStudio via WSDL.
Dim myService As New egService.egServiceClient
myService.ClientCredentials.UserName.UserName = "myUserName"
myService.ClientCredentials.UserName.Password = "mySecretPassword"myService.doSomeStuff()
In my web.config I have the client-endpoint and a basicHttpBinding (security mode = TransportWithMessageCredential" and clientCredentialType = "Basic"). The last view times I had to integrate such a webservice, this was the way to go and everything worked.
Am I completely wrong and this is just NOT the way to go?
Feb 24, 2016 11:43 PM|mgebhard|LINK
I'm not sure if I'm completely wrong, but I'm not making a HTTPRequest
Well, you;re making an HTTP request.
I'm using the Webreference created in VisualStudio via WSDL.
Correct and unless otherwise noted by the service provider it's SOAP over HTTP.
Am I completely wrong and this is just NOT the way to go?
As I said above I believe this is actual Basic Authentication. The previous link explains the format of Basic Authentication. The following link shows how to add a header to a service request.
You might consider contacting the service's support to get help.
Feb 25, 2016 07:22 AM|Abrakamadpa|LINK
Thanks a again for your help and your patience! I really appreciate this.
I'm sorry to bother you again and it might seem as if I have completely no clue what I'm doing - which might be correct in some way :(
Well, I am making a HTTP Request - at least the code does. In my case, the whole logic of the communication between my code and the webservice is enbedded in the proxy-class generated by Visual Studio by the "add web-reference"-tool. So in the end, I just
have my proxy-class (as some kind of black-box) over which I'd like to communicate with the SOAP-Webservice.
The documentation you provided suggests adding the header like this:
Dim mySoapHeader As MyHeader = New MyHeader()
mySoapHeader.Username = UserName
mySoapHeader.Password = SecurelyStoredPassword
Dim proxy As MyWebService = New MyWebService()
proxy.MyHeaderValue = mySoapHeader
Dim results as String = proxy.MyWebMethod()
Well, I can create the soapHeader-Object and add username and password. And I can create the Service-Object based on the proxy-class provided by VS. But I can't add the header, as the Service-Object hasen't got a property like "myHeaderValue" or anything
else concerning the header.
My Service-Class exposes (beside the properties and methods specific for this service) a property "ClientCredentials" (which I can fill up with whatever I want - it doesn't help). But I can't see any possiblity to add this specific header.
Again, of course, it's possible that I'm not seeing the point, that I have no clue what I'm doing and that anyone with just a little more knowledge of this subject would solve the problem in seconds. I've got no problem with this. The point is: I have to
get this webservice integrated and I'm open to any help I can get. So if you think that I just have no clue and that you would be able to help, I would happily accept this (including paying you the time you invest).
Feb 25, 2016 12:31 PM|mgebhard|LINK
You really should contact support for the service you are trying to consume. Creating a service reference and hoping for the best is not the way to solve the problem. You need to know how the service works.
I'm guessing, due to the error, that the service wants HTTP Basic Authentication not WCF basic authentication. HTTP Basic Authentication has been around a long time and it uses a base64 encoded "Authorization:" headers to validate requests.
Here is an example of adding a Basic Authentication header to the client proxy created with the web reference tool in Visual Studio.
static void Main(string args)
string username = "foo";
string password = "bar";
//Encrypt the username and password
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
AsmxService.ClassicWebServiceSoapClient client = new AsmxService.ClassicWebServiceSoapClient();
using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)client.InnerChannel))
//Add the header
//Invoke the service
The resulting HTTP request with the authorization header.
POST http://xps:46579/ClassicWebService.asmx HTTP/1.1
Content-Type: text/xml; charset=utf-8
Accept-Encoding: gzip, deflate
<HelloWorld xmlns="http://tempuri.org/" xmlns:a="http://schemas.datacontract.org/2004/07/AnythingConsole.AsmxService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
I'm not sure this will sove your problem. Again, I'm basing this solely on the error message in your first post. Consider reading the support documentation for the service you are trying to consume.
Feb 25, 2016 01:23 PM|Abrakamadpa|LINK
Thanks a lot for this input! Your example helped me to add the HTTP-Header to the request. Seems as if this is the right track! I now get the error:
There was an error while decoding the authentication information in the http header
Now, that's way better :)
I'm now going to ask the service-provider in which format they need Authentication-header.
I hope I'm going to succeed after all - thanks to you.