2

我希望在 SOAP 标头中发送一些信息,例如身份验证令牌。我正在使用 gSOAP/c/Linux。请帮我如何通过?

我的SOAP_ENV__Header样子

/* SOAP Header: */
struct SOAP_ENV__Header
{
    struct ns3__Header *ns3__MyHeader;  /* mustUnderstand */
};

看起来ns3__Header

/* ns3:Header */
struct ns3__Header
{
    char *Value;    /* optional element of type xsd:string */
};
4

1 回答 1

2

很抱歉打扰大家了。我想到了。我是这样做的:

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

但我不得不抑制 MustUnderstand 属性,如下所示:

SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
{
      if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Header), type))
            return soap->error;
      //KNG
      //soap->mustUnderstand = 1;
      if (soap_out_PointerTons3__Header(soap, "ns3:MyHeader", -1, &a->ns3__MyHeader, ""))
            return soap->error;
      return soap_element_end_out(soap, tag);
}
于 2010-04-15T08:11:22.743 回答