简体   繁体   中英

Pass all default response values through Payload Mediator in WSO2 esb

I am using payload mediator in a proxy service deployed on WSO2 ESB to map legacy values to new ones. It works fine but it only shows values that i have transformed. I want it to show rest of response as well. Is there anyway to do it by using payload mediator or any other mediator?

WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="Person_Proxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <send>
            <endpoint>
               <address uri="http://www.example.com/xsd/Person_01_RequestResponse_001"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <payloadFactory media-type="xml">
            <format>
               <m:GetPersonResponse xmlns:m="http://example.com/TimeWriter/Person">
                  <m:NationalIdentityNumber>$1</m:NationalIdentityNumber>
                  <m:CountryCode>$2</m:CountryCode>
                  <m:FirstName>$3</m:FirstName>
                  <m:LastName>$4</m:LastName>
                  <m:HomePhone>$5</m:HomePhone>
               </m:GetPersonResponse>
            </format>
            <args>
               <arg xmlns:m0="http://www.example.com/xsd/Person_01"
                    evaluator="xml"
                    expression="//m0:CNIC"/>
               <arg xmlns:m0="http://www.example.com/xsd/Person_01"
                    evaluator="xml"
                    expression="//m0:Country"/>
               <arg xmlns:m0="http://www.example.com/xsd/Person_01"
                    evaluator="xml"
                    expression="//m0:FirstName"/>
               <arg xmlns:m0="http://www.example.com/xsd/Person_01"
                    evaluator="xml"
                    expression="//m0:LastName"/>
               <arg xmlns:m0="http://www.example.com/xsd/Person_01"
                    evaluator="xml"
                    expression="//m0:HomePhone"/>
            </args>
         </payloadFactory>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="http://localhost:8080/Person_01/services/PersonSOAP"/>
      </endpoint>
   </target>
   <description/>
</proxy>

I am getting only four attributes now in response which i have explicitly transformed. I want rest of attributes too. I am using SoapUI tool to test this service.

There are multiple options that you could try, ie use a xslt mediator, script mediator or you can have your own custom mediator to implement this transform logic. If you planing to go only with payload mediator you have to modify payload factory to include everything, It only outputs the content that you specified in between the "format" tags and nothing more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM