1
votes

I saved the following structure on a property du wso2:

<ELEMENT>
   <ELEMENT_2>
   <ELEMENT_3>
   <ID> 173993 </ID>
   </ELEMENT_3>
   </ELEMENT_2>
   </ELEMENT>

I want to bring TEMP only to children:

<TEMP>
            <NAME>GEORGE</NAME>
            <COGNOME>MENDEZ</COGNOME>
            <BUSINESSNAME/>
            <CHANNEL>X091</CHANNEL>
        
   </TEMP>

I want to add them right after the <ELEMENT_2>

FINAL RESULTS:

 <ELEMENT>
   <ELEMENT_2>
   <NAME>GEORGE</NAME>
   <COGNOME>MENDEZ</COGNOME>
   <BUSINESSNAME/>
   <CHANNEL>X091</CHANNEL>
   <ELEMENT_3>
   <ID> 173993 </ID>
   </ELEMENT_3>
   </ELEMENT_2>
   </ELEMENT>

Thanks

1

1 Answers

1
votes

Can you check if your requirement is achieved with the following proxy configuration.

    <?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="enrichProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <property name="initial_payload" scope="default">
            <ELEMENT xmlns="">
               <ELEMENT_2>
                  <ELEMENT_3>
                     <ID>173993</ID>
                  </ELEMENT_3>
               </ELEMENT_2>
            </ELEMENT>
         </property>
         <call>
            <endpoint>
               <http uri-template="http://run.mocky.io/v3/7c578a1d-5427-4325-9f00-4ad7bb80dd04"/>
            </endpoint>
         </call>
         <log level="custom">
            <property expression="$body//TEMP/*" name="******"/>
         </log>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>

Remove external tag with xpath wso2

update

Here I have enriched the second property (..) back to the body using a enrich mediator.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="enrichProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <property name="initial_payload" scope="default">
            <ELEMENT xmlns="">
               <ELEMENT_2>
                  <ELEMENT_3>
                     <ID>173993</ID>
                  </ELEMENT_3>
               </ELEMENT_2>
            </ELEMENT>
         </property>
         <property name="second_payload" scope="default">
            <TEMP xmlns="">
               <NAME>GEORGE</NAME>
               <COGNOME>MENDEZ</COGNOME>
               <BUSINESSNAME/>
               <CHANNEL>X091</CHANNEL>
            </TEMP>
         </property>
         <enrich>
            <source clone="true" property="second_payload" type="property"/>
            <target type="body"/>
         </enrich>
         <enrich>
            <source clone="true" xpath="$body//TEMP/*"/>
            <target action="child" xpath="$ctx:initial_payload//ELEMENT_2"/>
         </enrich>
         <log level="custom">
            <property expression="$ctx:initial_payload" name="******"/>
         </log>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>