Sunday, February 27, 2011

Building an asynchronous web service with OSB

A few weeks ago I made a blogpost over how you can build an asynchronous web service with JAX-WS. In this blogpost I will do the same in the Oracle Service Bus. What you probably already know is that OSB Proxy Service does not support asynchronous calls. This does not mean that it is impossible to do asynchronous calls in the OSB.  To make this work I have the following setup.
A HTTP Proxy Service  -> JMS Business Service -> Queue -> JMS Proxy Service -> HTTP Business Service.

I start with the WSDL which has two operations execute and callback.
The execute operation is used in the HTTP Proxy Service and the callback operation in the HTTP Business Service. The HTTP Proxy Service does the following:
  • retrieves the Addressing MessageID from the header, $header/wsa05:MessageID/text() , In this case you need to use the 2005 / 08 addressing.
  • retrieves the Addressing Reply URL from the header, $header/wsa05:ReplyTo/wsa05:Address/text(). This URL will be used in the callback HTTP Business Service
  • Make a new Body for the Queue which contains the WS Request and the Reply URL
  • Set the JMS CorrelationID with MessageID as value, use the Transport Header activity
  • Call the JMS Business Service.   
The JMS Business Service put the Message on a Queue.

The JMS Queue has the following exception properties, these settings are very important else you can create a loop when something goes wrong, with these settings the message will be moved to the error queue when the dequeue proxy service fails twice.
The JMS Dequeue Proxy Service steps:

  • Dequeue the JMS Message
  • Retrieves the Addressing MessageID from the JMS header, $inbound/ctx:transport/ctx:request/tp:headers/jms:JMSCorrelationID/text()
  • Retrieves the ReplyURL from the body
  • Replace the header with this one <wsa05:RelatesTo>{$messageId}</wsa05:RelatesTo>
  • Set the URL with the ReplyURL value, set the URL in the Routing Options activity.
  • Call the HTTP Business Service.
The HTTP Business Service has a dummy url and uses the callback operation from the WSDL.

Deploy everything to the OSB Server and start SOAPUI so you can test this OSB project.

In SOAPUI you can import the WSDL of the HTTP Proxy Service. I will use the execute operation as test and  make a mock service based on the callback operation.
Start the mockservice and remember the url of this mock service
Create a request and enable WS-Adressing, put the mockservice url in the Reply To field and enable Randomly generate MessageId
The OSB will call your mock service with the response and uses RelatesTo element which contains the MessageId of the request.

Here you got the OSB export of my test project.

Sunday, February 20, 2011

Do your SOA deployments & configuration with AIA

One of the Application Integration Architecture (AIA) hidden gems is the SOA Suite / FMW deployment framework. This ANT framework can (un)deploy your WARS, SOA Composites, MDS, create JDBC Datasources & JMS Resources like Queues, Topics, Connection Factories , Deploy AQ, JMS, DB Resource Adapters and restart your WebLogic Server and can even do more things like update your WSDL. create users etc.

Before you install AIA you should know this is not license free, but this can save you a lot of money and helps you to reduce the human factor in your deployments.

This deployment framework is part of a bigger AIA plan and is based on Oracle Best practices, but this can also be used for environments where they don't work with AIA.

To use this deployment framework you should have a running SOA Suite & installed AIA on a machine. For installation instructions see my Whitehorses blog.

And here is the official documentation of this deployment framework.

The first step is to add your WebLogic ( SOA Suite ) Server and Database connections details to the AIAInstallProperties.xml file, this located in your AIA instance folder, in my case (
C:\oracle\AIAPS3\aia_instances\AIAInst1\config ).

Add your Database connections under /properties/participatingapplications/AIAEmployeeSync/db
AIAEmployeeSync is my demo application.

Add your WebLogic connections under /properties/pips/AIAEmployeeSync/server

In my case the password are already encrypted, but you need to encrypt them again. So set the isencrypted element to false and replace the encrypted password with their plain text values.
Now you can run a utility to encrypt it again.
open a command windows
cd C:\oracle\AIAPS3\util
ant -f createStore.xml generate -DPropertiesFile=%AIA_INSTANCE%\config\AIAInstallProperties.xml

This will encrypt all the password fields.

Now we can take a look at the deployment plan. Here you see for example the scott Datasource which we just configured in the AIAInstallProperties xml file and it has also a reference to the WebLogic server where it needs to deployed to. With ManagedServer you can reboot the WebLogic server and UpdateMetadata does the necessary MDS updates.

You can also make an undeployment plan. This is nice because you can re-test the whole deployment on your test or acceptance server.

I made a handy start script to start this deployment

Also for the undeploy

We are reading to start the deployment.
open a command window and go the location of your ANT xml's
cd C:\projecten\workspace\11g_prod\AIAEmployeeSyncPS3\config
ant -f deployEmployeeSync.xml

And if everything is Ok you should have everything installed & deployed, but you can always check your deployment log for errors.

When you look for your Resource Adapter definitions then you should look for AIA_XXX

But you can't change the EIS Connections because these are generated, so you need to do this with this AIA deployment framework.

The End

Saturday, February 12, 2011

Building an asynchronous web service with JAX-WS

Building an asynchronous web service can be complex especially when you are used to synchronous Web services where you can wait for the response in your favorite tool. To get the response of an asynchronous WS you need to do the following in SOAPUI,  create a MockService based on the WSDL of the Web Service and use this Mock Service URL in the ReplyTo Addressing property of your WS Request. Off course you need to enable Addressing where you also need  add a unique MessageId which can be used as a reference for the Response.

To start this blogpost, I begin with making a simple Hello interface. sayHello is the request operation and will use callbackMessage as response.

Then the Hello implementation
The next step is to retrieve the WSDL of this JAX-WS Service, you can start the HelloImpl Web Service by Running this class in JDeveloper and retrieve the WSDL or select the HelloImpl class and press show WSDL for Web Service Annotation ( also JDeveloper ).

This WSDL will be used to generate a Web Service Client project. I need these client classes to do a WS callbackMessage call out. You can do this in a separate project ( check the dependencies ) or in the same WS project.

Change the sayHello implementation, where I try to retrieve the replyTo address and the MessageId of WS-Adresssing. Make a new callbackMessage WS Request and set the reply URL and the relatesTo attribute

Restart your JAX-WS Service and test this service in SOAPUI or use the JDeveloper HTTP Analyzer. Make sure, you enable WS-Adressing and set a reply address, for example the SOAPUI Mock Service address

This is the callback request which is send to the SOAPUI Mock Service. It got the RelatesTo Addressing attribute. This is captured in the HTTP Analyzer of JDeveloper.

 And the same callback but then in the SOAPUI Mock Service request window
That's all.