Reputation: 626
I have a problem generating a gSOAP security header (WSSE). I have compiled all the necessary file and used the following calls to add the WSSE security header to the request:
soap_wsse_add_Security(proxy.soap);
soap_wsse_add_UsernameTokenText(proxy.soap, "UsernameToken-1", "user","passwd");
My security header comes out looking like this:
<SOAP-ENV:Header>
<wsse:Security SOAP-ENV:mustUnderstand="true">
<wsse:UsernameToken wsu:Id="UsernameToken-1">
<wsse:Username>testuser</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
testPassword</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
Compared to the server specification I was provided, the line
<wsse:Security SOAP-ENV:mustUnderstand="true">
is missing the xmlns:wsse="http...." and the line
<wsse:UsernameToken wsu:Id="UsernameToken-1">
is missing the xmlns:wsu="http...." parts. So I want the to look like this:
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="true">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1">
How do I add the xmlns:wsse and xmlns:wsu parts to the specific lines to be inline with the spec? The error I get from the service is:
com.ctc.wstx.exc.WstxParsingException: Undeclared namespace
prefix "wsse"
I have looked at the gSOAP documentation but all I could find was how to add a header, nothing on how to add namespace definitions to the items in the header.
Assistance will be appreciated.
Upvotes: 1
Views: 4201
Reputation: 449
Actually, you should not edit the .nsmap file, but rather the typemap.dat, which affects the automatic generation of .nsmap.
Use WS\WS-typemap.dat as a base (it already defines WS-SE namespaces) and provide it as an argument to wsdl2h command:
wsdl2h -t WS-typemap.dat ...
Upvotes: 3
Reputation: 626
Just answering the question to close it.
What you need to do is to edit the *.nsmap file. There you can add your namespace definitions in the struct for example:
SOAP_NMAC struct Namespace ZamtelWSZambia_namespaces[] =
{
{"wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-ecext-1.0.xsd", NULL, NULL},
{NULL, NULL, NULL, NULL}
};
Then in the client simply include the NSMAP like this:
#include "soapstubs/XXXX.nsmap"
Upvotes: 1