gSOAP:如何在soap标头中传递信息

发布于 2024-08-28 09:21:22 字数 393 浏览 4 评论 0原文

我希望在 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 */
};

I wish to send some information like authentication token inside SOAP header. I am using gSOAP/c/Linux. Please help me how to pass?

My SOAP_ENV__Header looks like

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

and ns3__Header looks like

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一影成城 2024-09-04 09:21:22

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

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

Sorry for bothering everybody. I figured it out. I did it like:

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

But I had to suppress the MustUnderstand attribute like the following:

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文