2010-04-12 66 views
2

我希望在SOAP標題內發送一些信息,如認證令牌。我正在使用gSOAP/c/Linux。請幫助我如何通過?gSOAP:如何傳遞肥皂標題內的信息

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 */ 
}; 

回答

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