[jboss-dev-forums] [Design of JBoss ESB] - Re: Transformation Actions to handle specific use cases

tfennelly do-not-reply at jboss.com
Fri May 8 05:54:23 EDT 2009


An action that allows you to perform some "rough" binding of data from an XML message into a simple Map structure might be useful.

As an example of what I mean...

XML:

  | <Order>
  |     <header>
  |         <orderId>1</orderId>
  |         <orderDate>Wed Nov 15 13:45:28 EST 20061</orderDate>
  |         <statusCode>0</statusCode>
  |     </header>
  |     <Customer userName="user1" firstName="Harry" lastName="Fletcher" state="SD"/>
  |     <Product productId="364" title="The 40-Year-Old Virgin " price="29.98"/>
  | </Order>
  | 

Suppose the service is only interested in the header and product info in this message, the ESB Config for binding that data out of this message and into a Map based model (i.e. untyped and in a Map) might look something like:


  | <action name="bindRequestData" class="org.jboss.esb.actions.XMLToMapBinder">
  |    <property name="bindings">
  |        <bean beanId="header" element="order/header" />
  |        <bean beanId="product" element="order/Product" />
  |    </property>
  | </action> 
  | 

This would allow the action following this action to access this info and use it in something like an MVEL or Groovy script e.g.:


  | def orderData = message.getBody().get();
  | def price = orderData.product.price;
  | 
  | if (price > 30.00) {
  |     def orderStatus = orderData.header.statusCode;
  |     def productId = orderData.product.productId;
  |     
  |     // Run some sort of check using the captured data...
  | }
  | 

Of course you could also just tell it to bind the complete message into a Map structure, but that has obvious performance issues.  Also, the likes of Groovy can do this for you anyway.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4229667#4229667

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4229667



More information about the jboss-dev-forums mailing list