gSOAP HTTP身份验证

gSOAP HTTP Authentication

本文关键字:身份验证 HTTP gSOAP      更新时间:2023-10-16

我正在使用gSOAP 2.8.15,并试图按照gSOAP文档第19.14节中的说明实现HTTP身份验证(http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sec9.14).

唯一的区别是文档中引入的代码是用C编写的,但我是用C++编写的。

这是我的代码客户端的网络服务

// 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);

在服务器端,我使用这些代码来检查身份验证:

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

问题是,当我使用客户端代码调用web服务的函数时,服务器端的userid和passwd总是为NULL。但是,当我使用soapUI通过以抢先授权模式传递userid和passwd来调用相同的函数时,服务器将毫无问题地获得信息。

如果有人能帮我解决这个问题,我将不胜感激。感谢您的关注。

我用tcpdump捕获了在web服务服务器和客户端之间发送的包,发现当客户端调用web服务的函数时,没有发送http头。因此,我在gSOAP的文档中进行了一些搜索,发现了以下句子:

客户端可以使用http://前缀。不存在时,没有HTTP标头发送,并且不会向服务

它解决了我的问题。。。