Hi Suhan,

Try the following,

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse";
       name="PayloadFactoryHeaderTest"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <loopback/>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <payloadFactory media-type="xml">
            <format>
               <theData xmlns="http://some.namespace";>
                  <theHeader>$1</theHeader>
                  <theBody>$2</theBody>
               </theData>
            </format>
            <args>
               <arg evaluator="xml" expression="$header"/>
               <arg evaluator="xml" expression="$body/*"/>
            </args>
         </payloadFactory>
         <enrich>
            <source xmlns:the="http://some.namespace";
                    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
                    clone="true"
                    xpath="//the:theHeader/soap:Header/*"/>
            <target xmlns:the="http://some.namespace";
                    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
                    xpath="//the:theHeader/soap:Header/."/>
         </enrich>
         <log level="full"/>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

On Wed, Jun 3, 2015 at 4:50 PM, Suhan Dharmasuriya <[email protected]> wrote:

> Hi,
>
> ESB 4.8.1
> I have been testing the following 2 scenarios in a fresh ESB 4.8.1 pack.
>
> As per my observations the header tag extracted is behaving in two
> different ways in the following
> two scenarios.
>
> *Proxy*
> <proxy name="PayloadFactoryHeaderTest"
>           transports="http"
>           startOnLoad="true"
>           trace="disable">
>       <target>
>          <inSequence>
>             <loopback/>
>          </inSequence>
>          <outSequence>
>             <log level="full"/>
>             <payloadFactory media-type="xml">
>                <format>
>                   <theData xmlns="http://some.namespace";>
>                      <theHeader>$1</theHeader>
>                      <theBody>$2</theBody>
>                   </theData>
>                </format>
>                <args>
>                   <arg evaluator="xml" expression="$header/*"/>
>                   <arg evaluator="xml" expression="$body/*"/>
>                </args>
>             </payloadFactory>
>             <log level="full"/>
>             <send/>
>          </outSequence>
>       </target>
>    </proxy>
>
> *scenario 1*
> *SOAP request*
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>    <soap:Header>
>       <hd:inHeaderA xmlns:hd="http://some.namespace
> ">InputHeaderValueA</hd:inHeaderA>
>       <hd:inHeaderB xmlns:hd="http://some.namespace
> ">InputHeaderValueB</hd:inHeaderB>
>    </soap:Header>
>    <soap:Body>
>       <input xmlns="http://some.namespace";>
>          <customData1>inputData1</customData1>
>          <customData2>inputData2</customData2>
>       </input>
>    </soap:Body>
> </soap:Envelope>
>
> *Response*
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>    <soap:Header>
>       <hd:inHeaderA xmlns:hd="http://some.namespace
> ">InputHeaderValueA</hd:inHeaderA>
>       <hd:inHeaderB xmlns:hd="http://some.namespace
> ">InputHeaderValueB</hd:inHeaderB>
>    </soap:Header>
>    <soap:Body>
>       <theData xmlns="http://some.namespace";>
>          <theHeader>*InputHeaderValueAInputHeaderValueB*</theHeader>
>          <theBody>
>             <input>
>                <customData1>inputData1</customData1>
>                <customData2>inputData2</customData2>
>             </input>
>          </theBody>
>       </theData>
>    </soap:Body>
> </soap:Envelope>
>
> *scenario 2*
> *SOAP request*
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>    <soap:Header>
>       <hd:inHeaderA xmlns:hd="http://some.namespace";>
>          <sub>InputHeaderValueA</sub>
>       </hd:inHeaderA>
>       <hd:inHeaderB xmlns:hd="http://some.namespace";>
>          <sub>InputHeaderValueB</sub>
>       </hd:inHeaderB>
>    </soap:Header>
>    <soap:Body>
>       <input xmlns="http://some.namespace";>
>          <customData1>inputData1</customData1>
>          <customData2>inputData2</customData2>
>       </input>
>    </soap:Body>
> </soap:Envelope>
>
> *Response*
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
>    <soap:Header>
>       <hd:inHeaderA xmlns:hd="http://some.namespace";>
>          <sub>InputHeaderValueA</sub>
>       </hd:inHeaderA>
>       <hd:inHeaderB xmlns:hd="http://some.namespace";>
>          <sub>InputHeaderValueB</sub>
>       </hd:inHeaderB>
>    </soap:Header>
>    <soap:Body>
>       <theData xmlns="http://some.namespace";>
>          <theHeader>
>             *<hd:inHeaderA xmlns:hd="http://some.namespace
> <http://some.namespace>">*
> *               <sub>InputHeaderValueA</sub>*
> *            </hd:inHeaderA>*
> *            <hd:inHeaderB xmlns:hd="http://some.namespace
> <http://some.namespace>">*
> *               <sub>InputHeaderValueB</sub>*
> *            </hd:inHeaderB>*
>          </theHeader>
>          <theBody>
>             <input>
>                <customData1>inputData1</customData1>
>                <customData2>inputData2</customData2>
>             </input>
>          </theBody>
>       </theData>
>    </soap:Body>
> </soap:Envelope>
>
> Here, the header with sub elements is extracted successfully with tags
> (scenario 2), whereas the header with a single element (without any sub
> elements in scenario 1) has failed to extract the tags in the payload.
>
> Shouldn't the behaviour of ESB be consistent in both the scenarios?
>
> Thanks,
> Suhan
>
>
>
> --
> Suhan Dharmasuriya
> Software Engineer - Test Automation
>
> *WSO2, Inc. *
>
> lean . enterprise . middleware
> Tel: +94 112 145345
> Mob: +94 779 869138
> Blog: http://suhan-opensource.blogspot.com/
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 

Best Regards,

Malaka Silva
Senior Tech Lead
M: +94 777 219 791
Tel : 94 11 214 5345
Fax :94 11 2145300
Skype : malaka.sampath.silva
LinkedIn : http://www.linkedin.com/pub/malaka-silva/6/33/77
Blog : http://mrmalakasilva.blogspot.com/

WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/
http://www.wso2.com/about/team/malaka-silva/
<http://wso2.com/about/team/malaka-silva/>

Save a tree -Conserve nature & Save the world for your future. Print this
email only if it is absolutely necessary.
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to