Oracle’s Enterprise Service Bus (ESB) is designed to implement service-oriented architecture (SOA) and event-driven architecture (EDA), providing a responsive, low-cost, high-impact framework for matching technology needs to business problems.
One of the powerful capabilities of Oracle’s ESB is the ‘Routing Service’ which caters for service virtualization through content based routing. It supports one way and request response operations. One of the challenges with service virtualization and the request response pattern is matching the response from the implementation service to the response that the routing service should return. There is no easy answer to this one, but the Oracle ESB provides some help. One is the transformation capabilities, but you would expect this from any ESB system. The really useful feature is being able to refer to the request in the response transformation. Oracle ESB does this by declaring a parameter to the XSLT called $ESBREQUEST.
Elements in the request can be referred to through XPATH. For example:
This is great, but there are a few things I need to draw to your attention:
- $ESBREQUEST refers to the root element of the request sent to the service implementation and not the request sent to the routing service. So, if your implementation service request structure is DoMethodRequest/MyParam then refer to MyParam as $ESBREQUEST/MyParam not $ESBREQUEST/DoMethodRequest/MyParam.
- You need to enter the XPATH manually because the mapper does not know the structure of the request.
- You have to specify ‘Include Request in the Reply Payload’ when defining the routing rule. This can not be added to the routing rule or XSL file through the tools afterwards.
The latter point is what I really wanted to cover in this article. At the moment, in version 10.1.3, you can not retrospectively ‘Include Request in the Reply Payload’ using the JDeveloper or the ESB console. When you use JDeveloper the first time it puts
in the XSL file and sets attachRequestPayload=”true” in the transformation element of the routingRule section of the routing service esbsvc file.
So, you can do this manually to retrospectively add ‘Include Request in the Reply Payload’ to your existing routing rules. Unfortunately the only way I have found to update the running ESB routing service routing rules with these changes is to to delete the routing service (through ESB console), shutdown JDeveloper, edit the esbsvc file manually, restart JDeveloper and then register the ESB project with the integration server.
The Oracle Mapper tool in JDeveloper which is used to edit XSL files does understand the parameter concept, so you can test your stylesheet in JDeveloper before deploying it. Just open the XSL file in JDeveloper, right click in the design view and select Test. Be sure to enter the ESBREQUEST parameter as an XML fragment. Don’t forget that ESBREQUEST corresponds to the request structure sent to the service implementation and not the request received by the routing service!
This ESBREQUEST parameter gives you the benefit of manipulating the reply such as returning correlation information or using the data from the request to perform filtering and other manipulation that the service implementation does not provide.
Should you wish to use data from the original request received by the routing service then you have to add elements manually to the request transformation. This will work at runtime if the implentation service doesn’t validate the request for extra elements not part of the schema. However, once you add these elements to the XSL transformation you will not be able to use the JDeveloper mapper as it does validate the target document structure against the schema.
5 thoughts on “ESBREQUEST in Oracle ESB Routing Services”
Hi PeterThanks for an interesting article.On a adjacent matter..Is there a way to pass header parameters between to routing services? The following pdf (http://www.oracle.com/technology/products/integration/esb/files/esb-presentation-headers.pdf) shows how you can pass header parameters between a file read and a file write, with a routing service in between. But what if you have two routing services in between (which i happen to have in my case). Do you have any suggestions on how to do this (if it can be done).RegardsKalle Viklund
Combine the getRequestHeader and setOutboundHeader as per the ‘esb-presentations-headers’ example. If you have routing service A invoking routing service B then do this in the routing service A request transformation. The header values will be passed along, but you have to explicitly map them. This is often done to propagate wsse security headers.
Hi PeterThanks, I got it to work.Kalle Viklund
Peter,I am a newbie to ESB, from reading your post I am wondering whether it is possible to use an XPATH expression to specify the routing rule map name?I want to have a file system adapter read an XML file, I break out the map name from the file and pass this to the routing rule map name?Is this possible?
Is it possible to access SOAP Headers through $ESBREQUEST variable?Note that I’ve already passed those headers through the Routing Service:xsl:variable name=”INGUID” select=”ehdr:getRequestHeader(‘/soap:Header/myGuid:GUID’,’soap=http://schemas.xmlsoap.org/soap/envelope/;myGuid=http://ibai.net/owsm;’)”xsl:variable name=”OUTGUID” select=”ehdr:setOutboundHeader(‘/soap:Header/myGuid:GUID’, $INGUID, ‘soap=http://schemas.xmlsoap.org/soap/envelope/;myGuid=http://ibai.net/owsm;’)”And then I want to inject that header in the Routing Service’s response:xsl:variable name=”header” select=”ehdr:setOutboundHeader(‘//myGuid:GUID’,$ESBREQUEST,’soap=http://schemas.xmlsoap.org/soap/envelope/; myGuid=http://ibai.net/owsm;’)”But I´m getting an empty header :_(Thanks a lot!