Showing posts with label 12c. Show all posts
Showing posts with label 12c. Show all posts

Tuesday, September 26, 2017

SOA is so Groovy

Recently, I have tested and debugged Web Service and to automate test & compare cases I've used good ol' Groovy script activity in the SoapUI TestCase. Coincidentally, I've worked on the PoC where SOA Suite standard features don't fit well project terms. Can't say I've dreamed it, rather napped after a lunch break: "What if I can melt SOA and Groovy? There is a lang:groovy element available in the SpringBean activity descriptor". Follow me and I show you how to deliver the modern functional language to your SOA composites.

Saturday, September 02, 2017

SOA 12c JavaScript: Shaken, not stirred

Have you ever faced XML/XPath limitations? I bet you have. Mostly it's related to the string manipulations. Parsing, complex replacements, regular expressions, array transformations, I don't even start about math or anything else, that every modern language has out of the box. In the Oracle SOA world, you are moaning and pull Java Embedded Activity to the process, every time when you need something like that.

Sure you could use Java string operations in XSLT but it means you should create XSLT document for that matter. SOA 12c is a game changer. With the native JSON support, it brings you JavaScript.
The question "Can I use JavaScript with my XML data?" has the answer: " Yes, You can!".

Sunday, August 27, 2017

XPath. One with the clingy attributes


Hi there. Winter is coming, just not today. Because today it's raining cats, dogs and gators; High Florida season is on his way and I have time for the another little trinket. It's based on the same data types we have played around with apples and oranges. It's not exactly related. but I've reused XML Schema to show you a little side effect of the XPath selector. You have run into that if you use strict type validation for each and every activity in your process, but I bet you don't. It's pretty normal to validate data on the edges, in the BPEL case - check the service input and make sure that you produce the response, that composite's clients expect to have.

 This minimalistic composite has only a few steps, but can simulate behavior we need:

  • Check Incoming XML document (using partner link property)
  • Perform XPath query by attribute value
  • Validate output  variable
  • Return response
The one truly interesting activity here is the assign SetResponse. Let's take a look into source code:
<assign name="SetResponse">
<copy>
 <from>
  <literal>
   <GroceryList xmlns="http://mmikhail.com/sample/xml/Orchard">
    <Item Name="Apples" Type="bushel">1</Item>
    <Item NMame="Pears" Type="pound">4</Item>
   </GroceryList>
  </literal>
 </from>
 <to expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">$VariableWitthAttributes</to>
</copy>
<copy>
 <from>$VariableWitthAttributes/ns2:Item[@Name="Apples"]</from>
 <to expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">$outputVariable.payload/client:response</to>
</copy>
</assign>

Activity populates variable with the array of the element Item. You can select Item from the list either by index or by attribute name. That's exactly what the second copy does.  It selects Item value with the attribute Name equal to "Apples". Nothing fancy so far, good old XPath expressions and assignments. The CheckOutput activity validates output message against XML Schema.  It's a string and we do not expect any traps here. Le'ts compile, deploy and test the process.

Ouch, validation failed with the error message:

<bpelFault>
 <faultType>0</faultType>
 <invalidVariables xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable">
  <part name="summary">
   <summary>Failed to validate bpel variable.
Validation of variable outputVariable failed.
The reason was: Attribute 'Name' not expected.
Please handle the exception in bpel.</summary>
  </part>
 </invalidVariables>
</bpelFault>

And if you check the assign activity you'll see that all element attributes have traversed to the target variable. I bet it's not exactly what you have expected to see, but you do and it's the same for 12c and 11g. The solution is quite simple, just slightly modify selector for instance:

 <from>string($VariableWitthAttributes/ns2:Item[@Name="Apples"])</from>

Now composite works exactly as expected.

It looks like nothing, but think about it:
You have selected something by one attribute, but in fact, you have exposed not only this one but all of them and they may contain some sensitive information, like dates, user names, entity IDs and so on.
Hope it will help you to build more reliable and secure applications. Good luck with that.



Saturday, July 22, 2017

JSON in DB 12c: One more reason to upgrade

If you have not upgraded your Oracle database to the 12c version or you are considering database for your new project, than check this neat feature of the Oracle Database 12c. It may outweigh the competitors.

Friday, July 07, 2017

XSLT. Apples and Oranges.


Believe me or not, I'm not going to compare XSL processors or whining about poor support for XSLT 2.0. Recently I have faced the situation,  where I should merge two property lists and produce combined result. Let's do some shopping and play with the grocery lists. The reasons why I'm writing this post are:

  • SOA 11g/12c supports XSLT 2.0 transformations and you can use all the power of it. 
  • XSLT Mapper is far behind the processor and may eve lie to you with the error messages. 
The example below is a little trinket, but it may save you hours on developing external services for the data transformation.