Tuesday, 18 December 2012

How to use java callout in osb


Key Concepts:


·         POJOs are used for the java Callout

·         No Special libraries or compilation is required

·         Java method must be static(technically public and static ) in order to be call by OSB

·         Java code must be packaged in a JAR file

·         The same Java Callout JAR can be called from multiple proxy services

Using Java Primitives:


There are few following steps

1.      Create simple java project ex: Java callout project and inside project create package ex: com.oracle.osb.project . Inside project create a class file SimpleCallout.java.

2.      Inside class file create two methods

Ø  One takes a string argument and return hello and whatever given string argument. its typically  Hello worlds type of scenario .

Ø  And next one takes two arguments and multiply both the arguments and returns product the two arguments.
3.      Java Code :
package com.oracle.osb.project;
public class SimpleCallout {
 public static String getGreeting(String name)
 {
  return "hello" + name;
 }
 public static int multiply(int a,int b)
 {
  return a*b;
 
 }
}
4.      Basically Compile this. Right click on Java callout project -> Build Path->Add external archives.
5.      In order to access oracle Service Bus project change Recourse to oracle Service Bus.
6.      Create OSB configuration project and inside configuration project create OSB project.
7.      Now create 3 folders
Ø  WSDLs
Ø  Proxy services
Ø  JAR
8.      Inside WSDLs folder create wsdl file that defines the element.
Ø  Define two elements getGreeting and Multiplication.
Ø  getGreeting takes string argument and returns string back
Ø  Multiplication takes two different integer argument and return single integer result argument.
Ø  Wsdl file look like
 
9.      Now copy the Java callout.jar to JAR folder.
10.       Create proxy service inside proxy services folder.
Ø  Select general view and select WSDL Web Services.
Ø  Browse WSDL particular WSDL file and port.
Ø  Now go to Message fellow Create Operational branch one for Greeting and another for Multiplication
Ø  Select getGreeting Branch and drag and drop Pipeline pair.
Ø  Create stage in Request pipeline and inside stage create Java callout.
Ø  And go to Java callout properties tabs. Browse to the jar file. ex: javacallout.jar and specific operation in case is greeting.
Ø  Now pass the arguments. Click on expression and pass getGreeting argument. Ex: $body/proxy:getGreeting/in/text()
Ø  Result come back . and map that into greeting. Result value is greeting.
Ø  In Response pipeline Create stage. And inside stage create Assign and replace operation .
Ø  Select Assign operation. Click on Expression and write particular expression, Ex: <proxy:getGreetingResponse>
<out>{$greeting}</out>
</ proxy:getGreetingResponse>
Ø  And variable is responseDoc.
Ø  Now select Replace operation.
                                                              i.      XPath: .
                                                            ii.      In Variable: body
                                                          iii.      Expression : $responseDoc
                                                           iv.      And check Replace node contents  
11.      Do same steps for multiplication branch
12.      Message Fellow Look Like
 
13.      Now debug on server.

When to use a java call out:

Ø  New to the oracle service bus programmer.
Ø  Custom Validation
Ø  Custom Transformation
Ø  Custom Authentication
Ø  Lookups for message enrichment
Ø  Custom routing rules
 

Best Practices :

Ø  Keep JavaCallout JAR file small and simple
Ø  The JAR is dynamically loaded when they are first referenced
Ø  Large Java frame work libraries should be on the system class of the server
Ø  Avoid creating threads in JavaCallout code
Ø  POJOs must be thread safe

Monday, 17 December 2012

Steps to Configure MQ-Adapter on Weblogic server

a. Open the Weblogic Console by hitting the URL 

b.Enter the valid credentials and click on Login button.

c. On the home page click on the deployments located on extreme left side of the page

d.In the deployments click on the MQSeriesAdapter.

e.On the SettingsforMQSeriesAdapter click on the Configuration tab.

f.In the configuration tab click on the OutboundConnectionPools. Here we will specify Outbound connection properties JNDI to connect to MQ.

g.On the OutboundConnectionsPools tab you will be able to see javax.resource.cci.ConnetionFactory under which eis/MQ/MQAdapter Connection Factory is already created.

h.Click on the new button to create the connection factory to connect to your MQ.

i.It will open Create a New Outbound Connection dialogue. In Outbound Connection Groups select javax.resource.cci.ConnectionFactory and click on next

j.In next screen you need to give the JNDI name for your connection. It should be same as you configured in JDEV which is eis/MQ/MQSeriesAdapter. Please have a look at step k of section 2.2. After entering the JNDI name click on Finish.

k.You will and to Outbound Connection Pools tab and you will find your connection factory listed there.

l.Click on your connection factory and you will land to Properties tab.

Configure the following properties:

•channelName – MQChannel name configured on MQ server for your QueueManager. In our case it is MYCHANNEL.
•connectionFactoryLocation - MQAdapter.ConnectionFactory
•hostname – Hostname of the server where MQ is installed.
•portNumber – Port Number where the MQlistener configured for QueueManager is listening. In our case it is 7001.
•QueueManagerName - Name of the QueueManager.
•SSLEnable – false
•XATransaction - false.


m.Now go to Deployments and click check MQSeriesAdapter and click on update button present at the top of the deployment table.

n.After that in Update Application Assistant Window keep the default values

o.  Copy com.ibm.mq.jar in domain/lib folder and restart the server.

p. On next page click on finish button. You are ready to use the MQAdapter

MQ ADAPTER Configuration

1. MQ Adapter


1.1 Overview


In our real world applications there would be certain scenario’s where we would be requiring persistence in our applications. There would be certain third party applications which would expose their interaction interfaces in the form of jms Queues. There are certain vendors which have their own jms implementation. IBM is one of them which provides jms implementation in the form of product IBM MQ. IBM MQ Is the IBM implementation of jms concepts. Similarly, we have other vendors which provide their own jms implementation. For ex: Oracle AQ etc. We cannot interact with these different jms implementations directly. We need to write some custom code or an adapter which would serve this purpose and enable intercommunications. Here Oracle provides out of the box adapters which serve the purpose of adapter for communication. We jeust need to configure them.

1.2 Problem Statement


Here we will learn how to configure Oracle MQ Adapter which is provided by Oracle to interact with the IBM MQ.


2. MQ Adapter Configuration


2.1 Overview


This section will guide you how configure MQ adapter to communicate with IBM MQ.


2.2 Steps to Configure MQ-Adapter in JDEV

 

a. Open JDEV and click on file tab and then New.
 
 
 b. You will be presented with a New Gallery Pop-Up.
 
c. Go to the All Technologies tab and select SOA Application on the bottom right hand-side and click Ok.
d. Name your Dialogue will appear. Enter a valid Application Name in Application Name text box. For ex MQAdapterApplication keeping the other values as default values and click on next.
 
 
e. You will be presented with name your project screen. Enter a valid Project name. for ex: MQConfigurationProject and click on next. 
f. You will be presented with Configure SOA settings screen.
 
 
 g. In this page select Composite Template as Empty Composite and click on Finish.
 
 
 
h. A new Application and project will be created and composite.xml will be opened in your editor
 

i. Drag and drop MQ Adapter from component palette to External Reference swim lane in j-Developer. It will open MQ Series Adapter Configuration
 
 
j. Click on Next and you will land to Service Name Page. Enter the valid Service Name and click on Next. For ex: ClientInteractionService. 
 
 
 
k. You will land to MQSeriesConnection page. Specify the MQSeriesConnectionJNDI name and remember this name. We will use this name in server side configuration which will be used to connect to MQ. For ex: eis/MQ/MQSeriesAdapter. After that click on Next.

l. After that you will land to Adapter Interface. Here you have two options either you can define it from an existing WSDL or from schema specified later. In our case we will use Define from operation and schema(specified at a later stage) and click on next.

m. Now you will be presented with OperationType window in which you will have to choose an operation. In our case we will select PutMessageintoMQ operation and click on next.


 n. Next screen is PutMessageintoMQ screen. In QueueName enter the name of the Queue which is configured on MQ server. InQueueManager text enter the name of the QueueManager to which the queue is associated. Keep other fields as default and click on next.
 
o. Next screen is AdvancedOptions screen. Keep all the values to default and click on next.
p. Next screen which is Messages screen will ask you to specify the schema. Browse for the schema and select the message format to put into MQ. In our case it is customerInteractionProcessRequest of clientInteraction.xsd as attached below.
 

q. After selecting the message format click on next.
r. You will be able to see the Finish page. Click on the finish button

s. You will be able to see the MQAdapter Reference component in JDeveloper now