如何在Worklight SOAP适配器过程中传递SOAP Header参数?

时间:2016-02-04 07:09:42

标签: java soap ibm-mobilefirst mobilefirst-adapters mobilefirst-studio

我使用了IBM MobileFirst Studio V7.1 - 服务发现向导选项,并从应用程序WSDL文件创建了SOAP适配器。 Service Discovery过程在MFP Studio中正确创建MobileFirst适配器

消息有效负载如下所示

<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>

现在,使用MobileFirst Studio中的适配器测试选项,在对话框窗口中传递以下JSON有效负载

程序参数

params:

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

标题

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

但是,当适配器执行

时,我收到以下错误
{
   "errors": [
      "Class Cast: com.worklight.common.js.util.JSObjectConverter$1 cannot be cast to java.lang.String"
   ],
   "info": [
   ],
   "isSuccessful": false,
   "warnings": [
   ]
}

WS安全标头块是否以正确的格式传递?

由于

1 个答案:

答案 0 :(得分:0)

参数的格式与标题的格式不同。您有正确的参数格式。对于标头,它需要是仅包含键和值列表的JSON。请参阅以下文档: 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