Question

I'm working with gSOAP 2.8.15 and I'm trying to implement the HTTP Authentication by following the instructions in section 19.14 of gsoap documentation (http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc19.14).

The only difference is that the codes introduced in the documentation is written in C but I'am coding in C++.

Here is my codes for client side of the web service

// The variable wsp is a instance of web service proxy generated by soapcpp2.
// The proxy is a sub-class of the class soap
wsp.userid = "user";
wsp.passwd = "password";
// call the function of web service
wsp.get_version(&result);

In the server side, I use these codes to check the authentication:

// The variable wss is the a instance of web service service generated by soapcpp2. 
if (wss.userid == NULL || wss.passwd == NULL)
    //......

The problem is when I call the function of web service using the client-side code, the userid and passwd is always NULL in server-side. But when I call the same function using soapUI by passing the userid and passwd with preemptive authorisation mode, the server will get the information without problem.

I appreciate if anyone can help me work out the problem. Thanks for your attention.

Was it helpful?

Solution

I have used tcpdump to catch the package sent between web service server and client and I found that there is no http header sent when the client call the function of the web service. So I have done some search in the documentation of gSOAP and found this sentence:

A client may use the http:// prefix. When absent, no HTTP header is sent and no HTTP-based information will be communicated to the service.

It solves my problem...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top