gsoap在Header中加入参数
在http://www.w3.org/Submission/ws-addressing/的第2.3节Binding Endpoint References中描述了将reference parameter加入到<S:Header></S:Header>的情况。
我想使用gsoap实现这一功能,但不知道如何入手,例如我想将<fabrikam:CustomerKey>123456789</fabrikam:CustomerKey>加入到<S:Header></S:Header>中。
在gsoap中有wsseapi.h和wsaapi.h文件,分别是加密和WS-Address的内容。
如果我要在<S:Header></S:Header>中加入SSL加密,我可以使用
soap_wsse_add_Security(&m_soapManager);
soap_wsse_add_UsernameTokenDigest(&m_soapManager,"",username,password);
函数实现这个功能。
在SOAP_ENV__Header中定义如下:
/* SOAP Header: */
struct SOAP_ENV__Header
{
public:
struct _wsse__Security *wsse__Security;/* mustUnderstand */
char *wsa5__MessageID;/* optional element of type wsa5:MessageID */
struct wsa5__RelatesToType *wsa5__RelatesTo;/* optional element of type wsa5:RelatesTo */
struct wsa5__EndpointReferenceType *wsa5__From;/* optional element of type wsa5:From */
struct wsa5__EndpointReferenceType *wsa5__ReplyTo;/* mustUnderstand */
struct wsa5__EndpointReferenceType *wsa5__FaultTo;/* mustUnderstand */
char *wsa5__To;/* mustUnderstand */
char *wsa5__Action;/* mustUnderstand */
};
发现并没有可自定义的头内容,只能按照它规定好这些头来填值。
请教下,如何能在gsoap发送的XML协议<S:Header></S:Header中加入自定义的内容呢?如:
<S:Header>
...
<wsa:To>http://www.fabrikam123.example/acct</wsa:To>
<fabrikam:CustomerKey>123456789</fabrikam:CustomerKey>
<fabrikam:ShoppingCart>ABCDEFG</fabrikam:ShoppingCart>
...
</S:Header>
[最优解释]
要手动修改SOAP_ENV__Header结构体内容,并且在soap_out_SOAP_ENV__Header函数中加入对应内容,详细见:
http://www.cppblog.com/codejie/archive/2009/07/13/89972.html
[其他解释]
有没有人路过,给个思路也行啊
[其他解释]
没人知道吗?太悲剧了吧,求高手指点。
[其他解释]
有人路过吗?留句话也行啊,没人关注吗?
[其他解释]
楼上的方法可行,但是太复杂了,有没有更好的?