1

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.

mpromonet
  • 11,326
  • 43
  • 62
  • 91
Daniel Retief Fourie
  • 626
  • 2
  • 10
  • 20
  • Could you tell me how you add security header to a proxy object? I assume your above proxy variable is DeviceBindingProxy type, but I cannot see any such field in DeviceBindingProxy class. – mualloc Aug 12 '16 at 10:59

2 Answers2

3

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 ...
Daddy32
  • 429
  • 4
  • 16
1

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"
Daniel Retief Fourie
  • 626
  • 2
  • 10
  • 20