gpt4 book ai didi

c++ - gSOAP HTTP 身份验证

转载 作者:行者123 更新时间:2023-11-30 04:15:22 26 4
gpt4 key购买 nike

我正在使用 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)
//......

问题是当我使用客户端代码调用网络服务的功能时,用户名和密码在服务器端始终为 NULL。但是当我通过以抢占式授权模式传递用户 ID 和密码来使用 soapUI 调用相同的函数时,服务器将毫无问题地获取信息。

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

最佳答案

我用tcpdump抓取了web service server和client之间发送的包,发现当client调用web service的函数时,并没有发送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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com