2

我正在使用 c++ 中的 gsoap 包调用 Web 服务并获取响应。我还必须传递一些标头信息,我不知道该怎么做,因为我的标头是这样的 - /* SOAP Header: */

结构 SOAP_ENV__Header

{

上市:

void *dummy;    /* transient */

};

我错过了什么,或者应该只是这样,我们必须在这里进行更改?我在这里阅读了一些信息,但我的标题只是虚拟的。

其次,为了进一步调试,我想启用 DEBUGS,为此,根据用户指南,我已取消注释 stdsoap2.h 中的 DEBUG 宏并再次使用 DEBUG 标志构建,但我无法获得 .log文件被创建。任何想法?

迪帕克

4

2 回答 2

0

你可以做类似的事情

soap_init(&mysoap);
mysoap.header = (SOAP_ENV__Header *)soap_malloc(&mysoap, sizeof(SOAP_ENV__Header));
mysoap.header->ns3__MyHeader = (ns3__Header*)malloc(sizeof(ns3__Header));
mysoap.header->ns3__MyHeader->Value = (char*)malloc(10 * sizeof(char));
strcpy(mysoap.header->ns3__MyHeader->Value, str);
于 2011-11-16T11:48:17.933 回答
0

对于休息电话,这有效 -

#include "json.h"
#include <string.h>
#include "jsonStub.h"

struct Namespace namespaces[] = { {NULL, NULL} };
int main()
{
   struct soap *ctx = soap_new1(SOAP_XML_NOTYPE);
   soap_init(ctx);
   struct value *request = new_value(ctx);
   struct value response;

   ctx->sendfd = 1;   
   ctx->http_extra_header = "userName:abcd\r\npassword:xyz";
   *string_of(value_at(value_at(request, "add"), "i")) = "10";
   *string_of(value_at(value_at(request, "add"), "j")) = "20";

   json_write(ctx, request);
   printf("\n");
   if (json_call(ctx, "endpoint",request, &response))
   {
         printf( "json call failed " );
         soap_print_fault(ctx, stderr);
         printf("\n%d", ctx->error);
         printf("\n1: SOAP faultcode = %s\n", *soap_faultcode(ctx));
         printf("2: SOAP faultstring = %s\n", *soap_faultstring(ctx));
         printf("3: SOAP faultdetail = %s\n\n", *soap_faultdetail(ctx));
         soap_print_fault_location(ctx, stderr);

   }

   else
   {
         printf("Success !!!");
         json_write(ctx, &response);
   }

   soap_destroy(ctx);
   soap_end(ctx);
   soap_free(ctx);
   return 0;

}

于 2018-09-24T08:25:20.127 回答