I've having a difficult time trying to set a SOAP header using gsoap.
(我在尝试使用gsoap设置SOAP标头时遇到了困难。)
I've read the FAQ here: http://www.genivia.com/Help/FAQlist.html#g17 (我在这里阅读了常见问题解答: http : //www.genivia.com/Help/FAQlist.html#g17)
This answer wasn't any help: How to pass header information to the soap header SOAP_ENV__Header, in c++ using gsoap
(这个答案没有任何帮助: 如何在C ++中使用gsoap将标头信息传递给soap标头SOAP_ENV__Header)
It assumes some magical caste has taken place to caste the dummy element in SOAP_ENV__Header to the desired data type.
(假定发生了一些不可思议的种姓,将SOAP_ENV__Header中的哑元素种姓为所需的数据类型。)
Here's my code:
(这是我的代码:)
#include <stdio.h>
#include <time.h>
struct SOAP_ENV__Header {
char *authwsns__token;
char *authwsns__ip;
};
#define SOAP_TYPE_SOAP_ENV__Header struct SOAP_ENV__Header
#include "authservicesH.h"
#include "AuthServicesBinding.nsmap"
int
main(int argc, char **argv) {
struct soap *soap;
struct authwsns__GetTokenRequest *request;
struct authwsns__GetTokenResult *result;
soap = soap_new();
soap->header = (struct SOAP_ENV__Header *)soap_malloc(soap, sizeof(struct SOAP_ENV__Header));
soap->header->authwsns__token = "jc09bdd";
soap->header->authwsns__ip = "10.10.10.10";
request = (struct authwsns__GetTokenRequest *)malloc(sizeof(struct authwsns__GetTokenRequest));
result = (struct authwsns__GetTokenResult *)malloc(sizeof(struct authwsns__GetTokenResult));
request->tokenBase = id;
soap_call___authwsns__getToken(soap, "http://", NULL, request, result);
if (result->tdsns__errorReport) {
printf("Web services error
");
printf("Level: %s
",result->tdsns__errorReport->level);
printf("Message: %s
",result->tdsns__errorReport->message);
} else {
printf("Token is %s
",result->token);
}
soap_end(soap);
soap_free(soap);
free(request);
free(result);
}
When I run my program through a debugger and display SOAP_ENV__Header, it still shows it as having a dummy element, so I'm not sure what the correct way to override the default definition is.
(当我通过调试器运行程序并显示SOAP_ENV__Header时,它仍然显示为具有虚拟元素,因此我不确定重写默认定义的正确方法是什么。)
The explanation in the FAQ is fairly vague about the details of this. (常见问题解答中的解释对此相当含糊。)
When I hack the Stub.h file with my definition of SOAP_ENV__Header and set values in it, the correct fields show up when I run it through the debugger, but they don't show up in the output XML.
(当我使用SOAP_ENV__Header的定义修改Stub.h文件并在其中设置值时,通过调试器运行该文件时会显示正确的字段,但不会显示在输出XML中。)
What am I missing here ?
(我在这里想念什么?)
Thanks, John (谢谢,约翰)
ask by jc9464 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…