Creating a template in Oracle Service Bus 12C

In this article I will show how to use the new templating functionality in Oracle Service Bus 12C. When building a lot of services through different projects, you will always duplicate certain functionality such as Logging, Validation etc… All conform your current development rules and guidelines of the project. This means tedious copying and pasting of certain pieces of code and the old OEPE IDE isn’t always precise with that. 12C has a nice feature now which gives you the opportunity to template certain pieces of code and re-use them in other projects. Lets see how that works.

I am using the project I created in my previous post. You can download a zip containing the project at the bottom so you can start from there. The conversionrate service is still very plain. As I would like to follow the VETRO pattern, I would like to add validation. So lets add a validation pipeline to the flow. Drag the Pipeline icon from the resource pallet onto the Piplelines/Split Joins lane. Choose a name and choose next. Select our own WDSL located in the wsdl folder and unselect Expose as a Proxy Service option as we already have a proxy.

validationPipeline

Next delete the wire between the proxy and the ConversionRateServicePipeline and connect the proxy to the new ValidationPipeline and the ValidationPipeline to the ConversionRateServicePipeline.

pipeline

Now lets implement the validation. Double click the ValidationPipeline. As you can see it has already set the routing to the ConversionRateServicePipeline for you. Lets add a ValidationPipelinePairNode and a request and response stage as you would normally do and add the validations steps.

validatePipelinePair

Next deploy and run a SoapUI test with an invalid enumeration type. You should get the following result:

validationFault

But we want some custom reply instead of a SoapFault so lets make that happen. We add an errorhandler to our Pipeline and catch the specific OSB-382505 error which is a validation fault. In that case we transform the Fault into a neat message for the client. The Replace would look like this.

<sch:Messages>
{
  for $message in $fault/ctx:details/con1:ValidationFailureDetail/con1:message
  return
    <sch:Message>
      <sch:Code>E-001</sch:Code>
      <sch:Description>{data($message/text())}</sch:Description>
    </sch:Message>
}
</sch:Messages>

Don’t forget to add the namespace with the value http://www.bea.com/wli/sb/stages/transform/config and the namespace with value http://www.redrock-it.nl/conversionrate/service/schema. Now, if you save and deploy and use SoapUI to make an invalid call, you will see the following result.

validationFaultProper

Now for the template creation part. We will want to re-use the ValidationPipeline in other services so what we do we click New->Pipeline Template. We give the template a name and select a location. Unfortunately it seems we cannot create it in a directory outside the project so lets just choose a template directory we just created. Select next and select for any SOAP and click finish and voila……we have a template for validation.

createTemplate

But how do we use it? Very simple. When you add a new Pipeline to the Pipelines/Split Join lane, you can choose a template at the bottom of the dialog. Choose the template you just created and voila….you have a completely filled Pipeline ready to go.

usingTemplate

One Reply to “Creating a template in Oracle Service Bus 12C”

  1. Pingback: Creating a template in Oracle Service Bus 12C | Hugo Hendriks

Leave a Reply

Your email address will not be published. Required fields are marked *

*