VMware Cloud Community
vmpancholy
VMware Employee
VMware Employee

soap header generation issue

Hi Team,

I'm trying to use SOAP 1.0.1 plugin within vCO. To help debug a few issues, I'm constructing the soap header programatically and trying to invoke the operation. When I generate the SOAP header, I find that the plugin omits a header value, eventhough I've supplied it as below.

Script code:

var request = operation.createSOAPRequest();

request.setInHeader("Security.UsernameToken.Username", "Username");

request.setInHeader("Security.UsernameToken.Password", "Password");

request.setInHeader("grid-name", "GRID01");

var response = operation.invoke(request);

Result:

<faultstring>  Summary: An unsupported request was received.

  Detail: The request received is:

Headers:

<grid-name xmlns="urn:realops.com:amp:workflow" />

<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

<UsernameToken>

<Username>TESTWSDL</Username>

<Password>password</Password>

</UsernameToken>

</Security>, Body Content: <Process__Response-Request xmlns="SA-VMware_Vcloud:Utilities" />

</faultstring>

Shouldn't the string in bold header contain "GRID01" ?

Mp

2 Replies
ChristianWehner
VMware Employee
VMware Employee

Hi,

had some errors too wanted to run some SOAP calls.

You could try to build your header by your own:

var header =    "<grid-name xmlns="urn:realops.com:amp:workflow">GRID01</grid-name>" +
     "<UsernameToken>" +
       "<Username>TESTWSDL</:Username>" +
       "<Password>password</Password>" +
    " </UsernameToken>" +
   "</Security>";

request.addRawHeader(header);

Regards,

Chris

Reply
0 Kudos
sanchezs
VMware Employee
VMware Employee

Hi,

You're right that the "grid-name" header should contain the value that you provide. We should make some test but maybe the issue is related to the namespace of the header... which is different from the one of the other header elements (and maybe it's the one taken by default).

What happens if you generate a workflow from that SOAP operation? Can you see the "grid-name" header as input parameter of the workflow?

As Chris says you can use the request.addRawHeader(...) method to workaround this issue.

Other option is to use the SOAPInterceptor object of the plug-in and to intercept your request before sending it and to inject the missing/problematic header manually, despite that you'll need maybe some more advance text/XML processing. Something like:

...
var interceptor = new SOAPInterceptor(); 
interceptor.setRequestHeaderInterceptor(requestHeaderHandler); 
...
var response = operation.invokeWithInterceptor(request, interceptor);
...

function requestHeaderHandler(content) { 
    System.log("This is the request header: '" + content + "'"); 
    // process & return your header here
}

I hope it helps.

Sergio