On Thu, Dec 30, 2010 at 9:38 PM, Hiranya Jayathilaka <[email protected]>wrote:

>
>
> On Thu, Dec 30, 2010 at 8:46 PM, Amila Suriarachchi <[email protected]>wrote:
>
>>
>>
>> On Thu, Dec 30, 2010 at 7:02 PM, Supun Kamburugamuva <[email protected]>wrote:
>>
>>> You can use a XSLT as well.
>>>
>>
>> Is this means I can't use Enrich mediator?
>>
>
> Enrich mediator is generally used to swap XML fragments in and out of
> messages.
>
you can do a transformation by doing such steps. Let me as this question
this way.

Lets say I get an xml like this

<ns2:
CustomerOrderProcessRequest xmlns:ns2="http://brs.carbon.wso2.org";>
    <ns2:Customer>
        <ns2:name>Amila</ns2:name>
        <ns2:rating>0.5</ns2:rating>
        <ns2:maxAmount>50</ns2:maxAmount>
        <ns2:Order>
            <items xmlns="http://pojo.sample.brs/xsd";>
                <price>50.0</price>
                <type>TypeA</type>
            </items>
            <items xmlns="http://pojo.sample.brs/xsd";>
                <price>60.0</price>
                <type>TypeB</type>
            </items>
            <ns1:orderID xmlns:ns1="http://pojo.sample.brs/xsd
">Order1</ns1:orderID>
        </ns2:Order>
        <ns2:Order>
            <items xmlns="http://pojo.sample.brs/xsd";>
                <price>50.0</price>
                <type>TypeA</type>
            </items>
            <items xmlns="http://pojo.sample.brs/xsd";>
                <price>60.0</price>
                <type>TypeA</type>
            </items>
            <ns1:orderID xmlns:ns1="http://pojo.sample.brs/xsd
">Order2</ns1:orderID>
        </ns2:Order>
    </ns2:Customer>
</ns2:CustomerOrderProcessRequest>

And I have an xml property (say myProperty) which contains following xml

<ns2:CalculatePriceRequest xmlns:ns2="http://brs.carbon.wso2.org"/>

Can I copy the Order elements to above element using enrich mediator?

Not sure how easy or suitable to implement a transformation using that.
>

yes we can use transformations but there are not performance wise effective
isn't it?

As I understood this is what enrich mediator does. Please correct me if I
wrong.

there is a source xml element which can be soap-header, soap-body, a
property or an inline.

Then we can specify a part of that xml (say sourceXML) using an XPath.

There is a target xml element again can be soap-header, soap-body or
property

then we can either replace, add as a child or sibling the sourceXML to a
given part of the target XML (again given as xml)

if so we should be able to many transformations using set of enrich
mediators in a performance effective way.

thanks,
Amila.



>
> Thanks,
> Hiranya
>
>
>>
>> thanks,
>> Amila.
>>
>>>
>>> Thanks,
>>> Supun..
>>>
>>> On Thu, Dec 30, 2010 at 6:29 PM, Paul Fremantle <[email protected]> wrote:
>>> > Do you need performance?
>>> > I love using E4X/JS mediator for this sort of thing!
>>> >
>>> > Paul
>>> >
>>> > On 30 December 2010 11:40, Amila Suriarachchi <[email protected]> wrote:
>>> >>
>>> >> hi,
>>> >>
>>> >> I try to write a sample which uses rules and ESB to process a customer
>>> >> order.
>>> >>
>>> >> For that I have this requirement.
>>> >>
>>> >> The esb proxy service receives a message like this,
>>> >>
>>> >> <ns2:CustomerOrderProcessRequest xmlns:ns2="
>>> http://brs.carbon.wso2.org";>
>>> >>     <ns2:Customer>
>>> >>         <ns2:name>Amila</ns2:name>
>>> >>         <ns2:rating>0.5</ns2:rating>
>>> >>         <ns2:maxAmount>50</ns2:maxAmount>
>>> >>         <ns2:Order>
>>> >>             <items xmlns="http://pojo.sample.brs/xsd";>
>>> >>                 <price>50.0</price>
>>> >>                 <type>TypeA</type>
>>> >>             </items>
>>> >>             <items xmlns="http://pojo.sample.brs/xsd";>
>>> >>                 <price>60.0</price>
>>> >>                 <type>TypeB</type>
>>> >>             </items>
>>> >>             <ns1:orderID
>>> >> xmlns:ns1="http://pojo.sample.brs/xsd";>Order1</ns1:orderID>
>>> >>         </ns2:Order>
>>> >>         <ns2:Order>
>>> >>             <items xmlns="http://pojo.sample.brs/xsd";>
>>> >>                 <price>50.0</price>
>>> >>                 <type>TypeA</type>
>>> >>             </items>
>>> >>             <items xmlns="http://pojo.sample.brs/xsd";>
>>> >>                 <price>60.0</price>
>>> >>                 <type>TypeA</type>
>>> >>             </items>
>>> >>             <ns1:orderID
>>> >> xmlns:ns1="http://pojo.sample.brs/xsd";>Order2</ns1:orderID>
>>> >>         </ns2:Order>
>>> >>     </ns2:Customer>
>>> >> </ns2:CustomerOrderProcessRequest>
>>> >>
>>> >> Then ESB has to send the following message to rule service.
>>> >>
>>> >> <ns2:CalculatePriceRequest xmlns:ns2="http://brs.carbon.wso2.org";>
>>> >>     <ns2:Order>
>>> >>         <items xmlns="http://pojo.sample.brs/xsd";>
>>> >>             <price>50.0</price>
>>> >>             <type>TypeA</type>
>>> >>         </items>
>>> >>         <items xmlns="http://pojo.sample.brs/xsd";>
>>> >>             <price>60.0</price>
>>> >>             <type>TypeB</type>
>>> >>         </items>
>>> >>         <ns1:orderID
>>> >> xmlns:ns1="http://pojo.sample.brs/xsd";>Order1</ns1:orderID>
>>> >>     </ns2:Order>
>>> >>     <ns2:Order>
>>> >>         <items xmlns="http://pojo.sample.brs/xsd";>
>>> >>             <price>50.0</price>
>>> >>             <type>TypeA</type>
>>> >>         </items>
>>> >>         <items xmlns="http://pojo.sample.brs/xsd";>
>>> >>             <price>60.0</price>
>>> >>             <type>TypeA</type>
>>> >>         </items>
>>> >>         <ns1:orderID
>>> >> xmlns:ns1="http://pojo.sample.brs/xsd";>Order2</ns1:orderID>
>>> >>     </ns2:Order>
>>> >> </ns2:CalculatePriceRequest>
>>> >>
>>> >> Currently I have the following ESB configuration which passes the
>>> received
>>> >> message as it is.
>>> >>
>>> >> <proxy name="CustomerOrderService" transports="https http"
>>> >> startOnLoad="true" trace="disable">
>>> >>         <target inSequence="CustomerOrderInSequence"
>>> >> outSequence="CustomerOrderOutSequence"/>
>>> >>     </proxy>
>>> >>     <sequence name="CustomerOrderInSequence">
>>> >>         <send>
>>> >>             <endpoint
>>> >> name="endpoint_urn_uuid_EA2F12A5E60B83D785297590854239961202342050">
>>> >>                 <address
>>> >> uri="http://111.223.141.139:9762/services/PriceCalculatorService"/>
>>> >>             </endpoint>
>>> >>         </send>
>>> >>     </sequence>
>>> >>     <sequence name="CustomerOrderOutSequence">
>>> >>         <send/>
>>> >>     </sequence>
>>> >>
>>> >> I need to get the orders from the received request and create the out
>>> put
>>> >> message.
>>> >> One options is to use the XSLT transformations instead of can I use
>>> the
>>> >> enrich mediator?
>>> >>
>>> >> If I use enrich mediator what are the steps?
>>> >>
>>> >> I tried to do following steps. But seems to be not working.
>>> >>
>>> >> 1. create a property with empty
>>> >> <ns2:CalculatePriceRequest xmlns:ns2="http://brs.carbon.wso2.org";>
>>> >>
>>> >> 2. Then copy the orders from the soap body to the element property.
>>> >> 3. Replace this property om element with the soap body.
>>> >>
>>> >> thanks,
>>> >> Amila.
>>> >>
>>> >> _______________________________________________
>>> >> Carbon-dev mailing list
>>> >> [email protected]
>>> >> https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Paul Fremantle
>>> > CTO and Co-Founder, WSO2
>>> > OASIS WS-RX TC Co-chair, VP, Apache Synapse
>>> >
>>> > Office: +44 844 484 8143
>>> > Cell: +44 798 447 4618
>>> >
>>> > blog: http://pzf.fremantle.org
>>> > twitter.com/pzfreo
>>> > [email protected]
>>> >
>>> > wso2.com Lean Enterprise Middleware
>>> >
>>> > Disclaimer: This communication may contain privileged or other
>>> confidential
>>> > information and is intended exclusively for the addressee/s. If you are
>>> not
>>> > the intended recipient/s, or believe that you may have received this
>>> > communication in error, please reply to the sender indicating that fact
>>> and
>>> > delete the copy you received and in addition, you should not print,
>>> copy,
>>> > retransmit, disseminate, or otherwise use the information contained in
>>> this
>>> > communication. Internet communications cannot be guaranteed to be
>>> timely,
>>> > secure, error or virus-free. The sender does not accept liability for
>>> any
>>> > errors or omissions.
>>> >
>>> > _______________________________________________
>>> > Carbon-dev mailing list
>>> > [email protected]
>>> > https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Supun Kamburugamuva
>>> Technical Lead
>>> WSO2 Inc.;  http://wso2.org
>>> E-mail: [email protected];  Mobile: +94 77 431 3585
>>> Blog: http://supunk.blogspot.com
>>> _______________________________________________
>>> Carbon-dev mailing list
>>> [email protected]
>>> https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>>
>>
>>
>> _______________________________________________
>> Carbon-dev mailing list
>> [email protected]
>> https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>>
>>
>
>
> --
> Hiranya Jayathilaka
> Senior Software Engineer;
> WSO2 Inc.;  http://wso2.org
> E-mail: [email protected];  Mobile: +94 77 633 3491
> Blog: http://techfeast-hiranya.blogspot.com
>
> _______________________________________________
> Carbon-dev mailing list
> [email protected]
> https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev
>
>
_______________________________________________
Carbon-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev

Reply via email to