On Fri, Dec 31, 2010 at 4:57 PM, Kasun Indrasiri <[email protected]> wrote:

> Yeah, Enrich mediator doesn't support multiple element. For your
> requirement, we can use the following config,
>
> <proxy name="PseudoProxy" transports="https http" startOnLoad="true"
> trace="disable">
>     <target>
>         <inSequence>
>             <log level="full"/>
>             <enrich>
>                 <source xmlns:ns2="http://brs.carbon.wso2.org";
>
>  xpath="//ns2:CustomerOrderProcessRequest/ns2:Customer/ns2:Order"/>
>                 <target type="property" property="ORDERS_REQ"/>
>             </enrich>
>             <log level="custom">
>                 <property name="BRS_REQ"
> expression="get-property('ORDERS_REQ')"/>
>             </log>
>             <enrich>
>                 <source type="inline">
>                     <ns2:CalculatePriceRequest xmlns:ns2="
> http://brs.carbon.wso2.org";>
>                         <ns2:foo/>
>                     </ns2:CalculatePriceRequest>
>                 </source>
>                 <target type="body"/>
>             </enrich>
>             <enrich>
>                 <source type="property" property="ORDERS_REQ"/>
>                 <target xmlns:ns2="http://brs.carbon.wso2.org";
> xpath="//ns2:CalculatePriceRequest/ns2:foo"/>
>             </enrich>
>             <log level="full"/>
>         </inSequence>
>         <outSequence>
>             <log/>
>         </outSequence>
>     </target>
> </proxy>
>
> But this only copies the first order element only. So, IMO we need to add
> this capability to enrich mediator.
>
+1

Thanks Kasun this what I wanted to do. Of course with all the Order elements
:).

BTW,  why this ns2:foo element? something you put to debug?

One thing about the enrich mediator.

In enrich mediator there are two things at source side.
1. Source xml element - this can be soap-header, soap-body, property or
inline.
2. Xpath expression to pick element for this particular enrich operation.

but currently there is a special type called custom and only on that case we
can specify the xpath. which is bit confusing.

thanks,
Amila.

>
> resulting message:
>
> [2010-12-31 16:37:33,760]  INFO - LogMediator To: /services/PseudoProxy,
> WSAction: urn:get_geo_app_profile, SOAPAction: urn:get_geo_app_profile,
> MessageID: urn:uuid:B0419F9F6B84FC49B01293793682385, Direction: request,
> Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Body>
>      <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:CalculatePriceRequest>
>    </soapenv:Body></soapenv:Envelope>
>
>
> On Fri, Dec 31, 2010 at 10:08 AM, Hiranya Jayathilaka <[email protected]>wrote:
>
>>
>>
>> On Fri, Dec 31, 2010 at 6:58 AM, Amila Suriarachchi <[email protected]>wrote:
>>
>>>
>>>
>>> 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?
>>>
>>
>> You have multiple Order elements in the input XML. So I don't think we
>> can. At least it's not going to be trivial.
>>
>> Thanks,
>> Hiranya
>>
>>
>>>
>>>  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
>>>
>>>
>>
>>
>> --
>> 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
>>
>>
>
>
> --
> Kasun Indrasiri
> Senior Software Engineer
> WSO2, Inc.; http://wso2.com
> lean.enterprise.middleware
>
> cell: +94 71 536 4128
> Blog : http://kasunpanorama.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