X

@OracleIMC Partner Resources & Training: Discover your Modernization options + Reach new potential through Innovation

How to use XSLT to extract information from a JMS MapMessage send by JMS Adapter (Oracle SOA Suite 12c)

Guest Author
SOA Suite logo Recently I have been playing with a sample SOA application integrated with a Stream Explorer exploration by means of JMS target. The concept was quite simple - whatever I detect in the SX exploration, I want to send it for further processing to a classical SOA composite by using JMS. You will find the idea and the result of this little PoC explained in our recent Stream Explorer Webcast. JMS is quite powerful mechanism for persistent messaging and it is quite easy to connect it declaratively as a Stream Explorer target. However, the shape of the data being send to the JMS Adapter is very generic, here you see some sample input:

<MapMessage xmlns="http://xmlns.oracle.com/pcbpel/adapter/jms/MapMessage">
   <entry name="id" dt="String" xmlns="">id_of_the_temperature_sensor</entry>
   <entry name="firstW" dt="Double" xmlns="">80.0</entry>
</MapMessage>

As you see, the XML structure is not very canonical, please take a look at the empty internal XML namespace declared within the "entry" tag. That  little obstacle took me some time to digest within the XSLT template, finally I had to use some unusual constructs to be able to extract those generic entries into some more canonical data shape. Here is the example of XSLT which works:

...
 
  <xsl:template match="/">
    <tns:WPattern>
      <tns:sensorId>
        <xsl:value-of select='/*/entry[@name="id"]'/>
      </tns:sensorId>
      <tns:firstW>
        <xsl:value-of select='/*/entry[@name="firstW"]'/>
      </tns:firstW>
    </tns:WPattern>
  </xsl:template>
 
...

this code generates a correct output as below:

<?xml version = '1.0' encoding = 'UTF-8'?>
<tns:WPattern xmlns:jca="http://xmlns.oracle.com/pcbpel/wsdl/jca/" xmlns:client="http://xmlns.oracle.com/SXDemoSOAApp/SXDemo/SXDemoBPELProcess" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/jms/SXDemoSOAApp/SXDemo/jmsService" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:pc="http://xmlns.oracle.com/pcbpel/" xmlns:plt="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:tns="http://www.sxdemo.com">
   <tns:sensorId>id_of_the_temperature_sensor</tns:sensorId>
 
   <tns:firstW>80.0</tns:firstW>
</tns:WPattern>

according the XSD schema defined in the SOA composite application:

<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sx="http://www.sxdemo.com"
            targetNamespace="http://www.sxdemo.com" elementFormDefault="qualified">
  <xsd:complexType name="WPatternType">
    <xsd:sequence>
      <xsd:element name="sensorId" type="xsd:string"/>
      <xsd:element name="firstW" type="xsd:double"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="WPattern" type="sx:WPatternType"/>
</xsd:schema>

Hope it helps in your own SX/SOA applications, whenever you want to use JMS in between. Happy streaming!


Facebook
Google+
Twitter
LinkedIn
Pinterest
Delicious
Digg
Addthis

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.