How to pass SOAP Header parameters in a Worklight SOAP adapter procedure?

276 Views Asked by At

I have used the IBM MobileFirst Studio V7.1 - Service Discovery wizard option and created a SOAP adapter from a application WSDL file. The Service Discovery procedure correctly creates the MobileFirst adapter in the MFP Studio

The message payload is shown below

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://siebel.com/CustomUI">
   <soapenv:Header>
      <ns1:Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="http://schemas.xmlsoap.org/ws/2002/07/secext">
         <ns1:UsernameToken>
            <ns1:Username>IBM</ns1:Username>
            <ns1:Password>IBM</ns1:Password>
         </ns1:UsernameToken>
      </ns1:Security>
   </soapenv:Header>
   <soapenv:Body>
      <cus:QueryJobDetails_Input>
         <cus:Object_spcId>SURV0332</cus:Object_spcId>
      </cus:QueryJobDetails_Input>
   </soapenv:Body>
</soapenv:Envelope>

Now, using the adapter testing option in the MobileFirst Studio, the following JSON payload are being passed in the dialog window

Procedure Arguments

params :

{"QueryJobDetails_Input":{"Object_spcId":"SURV0332"}}

headers:

{"UsernameToken":{"Username":"IBM","Password":"IBM"}}

But I get the following error when the adapter executes

{
   "errors": [
      "Class Cast: com.worklight.common.js.util.JSObjectConverter$1 cannot be cast to java.lang.String"
   ],
   "info": [
   ],
   "isSuccessful": false,
   "warnings": [
   ]
}

Is the WS Security Header block being passed in the correct format ?

Thanks

1

There are 1 best solutions below

0
On

The format for parameters is different from that of headers. You have the right format for parameters. For headers it needs to be JSON containing only a list of keys and values. Please see the following documentation: https://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/dev/c_invocation_generated_soap_adapter.html?lang=en