c++ - gSOAP HTTP 身份验证

标签 c++ http-authentication gsoap

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

唯一的区别是文档中介绍的代码是用 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 header 。于是我在gSOAP的文档中进行了一些搜索,发现了这样一句话:

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.

它解决了我的问题...

关于c++ - gSOAP HTTP 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18352297/

相关文章:

soap - 使用 GSoap 和 SSL 时遇到问题

ssl - gsoap 中的 ssl 客户端如何只向服务器发送 TLSv1 请求

C++ gSOAP wsdl 类型

c++ - 远程运行 C++ 程序;加载共享库时出错

c++ - 将文本和二进制数据连接到一个文件中

c++ - 如何丢弃 QEvent 而不是忽略它

JMeter 基本身份验证

php - HTTP 基本身份验证与 key

java - 无法使用 HTTP PUT 将用户添加到 CouchDB 中的数据库/_security

c++ - 如何在安装了 WSL 的 Visual Studio Code 中修复 "g++: error: helloworld.cpp: No such file or directory"?