IBM ESQL - 将 SOAP 信封添加到 XML 消息

IBM ESQL - Add a SOAP Envelop to XML Message

我编写了简单的消息流,其中 HTTPInput 节点接收 JSON 消息并发回 SOAP 消息。我添加了一个 HTTPInput, 计算和 HTTPReply 节点。计算节点具有以下 ESQL。

BEGIN

        SET OutputRoot.SOAP.users[] =
        (SELECT I.id AS id,
        I.name AS name,
        I.userName AS username,
        I.email AS email
        FROM InputRoot.JSON.Data[]
        AS I);

        RETURN TRUE;
    END;

当我拨打服务电话时,使用以下 JSON

{
    "id": 1,
    "name": "lalala Graham",
    "username": "Bret",
    "email": "Sincere@april.biz",
    "address": {
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      }
    }
}

我得到的 XML 响应是

<SOAP_Domain_Msg>
   <users>
      <id>1</id>
      <name>lalala Graham</name>
      <email>Sincere@april.biz</email>
   </users>
</SOAP_Domain_Msg>

我的问题是我希望在 SOAP 信封中进行响应。 我尝试在 HTTPReply 节点之前添加一个 SOAP Envelop 节点 但我收到以下错误。

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring>BIP3113E: Exception detected in message flow MFSamplej2s (integration node integration_server)</faultstring>
         <faultactor>http://localhost:7800/users</faultactor>
         <detail>
            <text>Exception. BIP2230E: Error detected whilst processing a message in node 'MFSamplej2s.SOAP Envelope'. : C:\ci\product-build\WMB\src\WebServices\WSLibrary\ImbSOAPEnvelopeNode.cpp: 280: ImbSOAPEnvelopeNode::evaluate: ComIbmSOAPEnvelopeNode: MFSamplej2s#FCMComposite_1_1
BIP3171E: A message using an incorrect parser ('SOAP') was detected in node: 'SOAP Envelope' : C:\ci\product-build\WMB\src\WebServices\WSLibrary\ImbSOAPEnvelopeNode.cpp: 613: ImbSOAPEnvelopeNode::getMessageBody: :</text>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

任何帮助都会非常有帮助。

我认为以下线程解释了几个选项。

https://www.ibm.com/mysupport/s/question/0D50z00005q4M4UCAU/example-for-converting-incoming-json-to-soap-message-in-esql-iib?language=en_US

这适用于以下代码。

SET OutputRoot.XMLNSC.ns1:citizen.ns1[] = 
    (SELECT I.username AS username,     
        I.personID AS personID, 
        I.familyName AS familyName, 
        I.title AS title, 
        I.dob AS dob 
        FROM InputRoot.JSON.Data[] AS I);

必须将 SOAP 替换为 XMLNSC,然后 SOAP 响应才来。实际上这是在 link @Supun 分享的。