如何使用enrich mediator使用WSO2 ESB将SOAP信封设置为XML正文

如何使用enrich mediator使用WSO2 ESB将SOAP信封设置为XML正文,wso2,wso2esb,Wso2,Wso2esb,我需要使用enrich mediator将soap信封设置为xml正文。 我在有效负载工厂中介器中创建了XML主体。我得到了那个物体的属性值。 财产 身体是这样的 <bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData"> <queryXpathExp> <soap:baseObj

我需要使用enrich mediator将soap信封设置为xml正文。 我在有效负载工厂中介器中创建了XML主体。我得到了那个物体的属性值。 财产

身体是这样的

<bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
<queryXpathExp>
    <soap:baseObjectInstance xmlns:soap="http:   //Here is only few lines
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples">
  <soapenv:Header/>
    <soapenv:Body>
      <bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
        <queryXpathExp>
          <soap:baseObjectInstance xmlns:soap="http://www.alcatel-lucent.com/soap_cm">
            hello
          </soap:baseObjectInstance>
        </queryXpathExp>
     </bas:setMOAttributes>
   </soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="test2"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
    <target>
      <inSequence>
         <property expression="$body/*[1]"
                   name="INPUT_MESSAGE"
                   scope="default"
                   type="STRING"/>
         <enrich>
            <source clone="true" type="inline">
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                  <soapenv:Header/>
                  <soapenv:Body>
                     <list xmlns=""/>
                  </soapenv:Body>
               </soapenv:Envelope>
            </source>
            <target type="envelope"/>
         </enrich>
         <enrich>
            <source clone="true" property="INPUT_MESSAGE" type="property"/>
            <target type="body"/>
         </enrich>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <list><![CDATA[<bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
       <queryXpathExp>
         <soap:baseObjectInstance xmlns:soap="http://www.alcatel-lucent.com/soap_cm">
          hello
         </soap:baseObjectInstance>
       </queryXpathExp>
     </bas:setMOAttributes>]]></list>
   </soapenv:Body>
</soapenv:Envelope>
现在我需要添加soap信封。我在输入消息属性之后使用了enrich mediator


用有效载荷工厂来做这个怎么样

$1
使用有效载荷工厂将为您提供一个干净的解决方案。如果要使用enrich mediator设置信封,需要先将其保存在属性中,然后在enrich mediator中使用属性。与您先在属性中保存主体,然后在丰富中介中使用主体所做的相同。 希望有帮助

试试这个,它会有用的

要求像这样的身体

<bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
<queryXpathExp>
    <soap:baseObjectInstance xmlns:soap="http:   //Here is only few lines
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples">
  <soapenv:Header/>
    <soapenv:Body>
      <bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
        <queryXpathExp>
          <soap:baseObjectInstance xmlns:soap="http://www.alcatel-lucent.com/soap_cm">
            hello
          </soap:baseObjectInstance>
        </queryXpathExp>
     </bas:setMOAttributes>
   </soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="test2"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
    <target>
      <inSequence>
         <property expression="$body/*[1]"
                   name="INPUT_MESSAGE"
                   scope="default"
                   type="STRING"/>
         <enrich>
            <source clone="true" type="inline">
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                  <soapenv:Header/>
                  <soapenv:Body>
                     <list xmlns=""/>
                  </soapenv:Body>
               </soapenv:Envelope>
            </source>
            <target type="envelope"/>
         </enrich>
         <enrich>
            <source clone="true" property="INPUT_MESSAGE" type="property"/>
            <target type="body"/>
         </enrich>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <list><![CDATA[<bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
       <queryXpathExp>
         <soap:baseObjectInstance xmlns:soap="http://www.alcatel-lucent.com/soap_cm">
          hello
         </soap:baseObjectInstance>
       </queryXpathExp>
     </bas:setMOAttributes>]]></list>
   </soapenv:Body>
</soapenv:Envelope>
像这样使用丰富中介的代理

<bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
<queryXpathExp>
    <soap:baseObjectInstance xmlns:soap="http:   //Here is only few lines
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples">
  <soapenv:Header/>
    <soapenv:Body>
      <bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
        <queryXpathExp>
          <soap:baseObjectInstance xmlns:soap="http://www.alcatel-lucent.com/soap_cm">
            hello
          </soap:baseObjectInstance>
        </queryXpathExp>
     </bas:setMOAttributes>
   </soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="test2"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
    <target>
      <inSequence>
         <property expression="$body/*[1]"
                   name="INPUT_MESSAGE"
                   scope="default"
                   type="STRING"/>
         <enrich>
            <source clone="true" type="inline">
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                  <soapenv:Header/>
                  <soapenv:Body>
                     <list xmlns=""/>
                  </soapenv:Body>
               </soapenv:Envelope>
            </source>
            <target type="envelope"/>
         </enrich>
         <enrich>
            <source clone="true" property="INPUT_MESSAGE" type="property"/>
            <target type="body"/>
         </enrich>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <list><![CDATA[<bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
       <queryXpathExp>
         <soap:baseObjectInstance xmlns:soap="http://www.alcatel-lucent.com/soap_cm">
          hello
         </soap:baseObjectInstance>
       </queryXpathExp>
     </bas:setMOAttributes>]]></list>
   </soapenv:Body>
</soapenv:Envelope>
像这样输出

<bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
<queryXpathExp>
    <soap:baseObjectInstance xmlns:soap="http:   //Here is only few lines
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples">
  <soapenv:Header/>
    <soapenv:Body>
      <bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
        <queryXpathExp>
          <soap:baseObjectInstance xmlns:soap="http://www.alcatel-lucent.com/soap_cm">
            hello
          </soap:baseObjectInstance>
        </queryXpathExp>
     </bas:setMOAttributes>
   </soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="test2"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
    <target>
      <inSequence>
         <property expression="$body/*[1]"
                   name="INPUT_MESSAGE"
                   scope="default"
                   type="STRING"/>
         <enrich>
            <source clone="true" type="inline">
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                  <soapenv:Header/>
                  <soapenv:Body>
                     <list xmlns=""/>
                  </soapenv:Body>
               </soapenv:Envelope>
            </source>
            <target type="envelope"/>
         </enrich>
         <enrich>
            <source clone="true" property="INPUT_MESSAGE" type="property"/>
            <target type="body"/>
         </enrich>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
      <list><![CDATA[<bas:setMOAttributes xmlns:bas="http://www.3gpp.org/ftp/Specs/archive/32_series/32607/schema/32607-700/BasicCMIRPData">
       <queryXpathExp>
         <soap:baseObjectInstance xmlns:soap="http://www.alcatel-lucent.com/soap_cm">
          hello
         </soap:baseObjectInstance>
       </queryXpathExp>
     </bas:setMOAttributes>]]></list>
   </soapenv:Body>
</soapenv:Envelope>