Showing posts with label Oracle OSB. Show all posts
Showing posts with label Oracle OSB. Show all posts

Monday, July 13, 2020

Database Adapter in OSB 12c

Hi! In this post, I'm going to show you how to use database adapter for selecting the data in the Oracle database in OSB 12c.

1. Create a service bus project with appropriate name.





2. Drag and drop a database adapter into the External Services swim lane. Give it an appropriate name and click Next.




Select the connection and click Next.




Select the Operation Type as Select and click Next.




Click on Import Tables to import the table(s) that we want.




Query the table that you wish to select the data from.




Click on the table name and click right arrow button to drop it into the Selected list.




Click Next.




Select the column that you want to make up the primary key and click Next.




Click Next.




Select the columns that you want to select and uncheck any columns that you don't want to be selected. Click Next.

 


Click on the Add button in the Parameters section to add a parameter.




Specify a name for the parameter. Click OK.




Now, click on highlighted Edit button to add the parameter to query.




Click on Add button and under second Argument section, select the radio button 'Parameter' and click OK.




After doing the above step, you should see your query concatenated with given parameter in the Where clause. Click Next.




In the next two screens, click Next to go with the default values.







Finally, click Finish.





3. Now create a proxy service. Right click on the Proxy Services swim lane. Insert Transports>HTTP.




Give it a proper name or leave it as it is to go with the default name. Check the check box 'Generate Pipeline' and click Next.




Select WSDL as Service Type. Browse the WSDL file in current project.




By default, database adapter creates two WSDL files. Select the one that contains '-concrete' as suffix. Click OK.




Click Next.




Click Finish.




Wire the Proxy service to db adapter as below.




Double click on the Proxy service. If you click on Routing, you'll see the selected business service.




We've done with all the steps, now deploy and test your service.

Saturday, July 11, 2020

Operational Branching in OSB 12c

Hi! In this post, I'm going to show you how to create a service bus project where operational branching is used assuming that you're familiar with Proxy Service and Pipeline. If you don't know how to create  a Proxy Service, please check out my previous post HelloWorld in OSB.

The example used in the current post shows an operational branching that consists of four operations - Addition, Subtraction, Multiplication and Division. So lets get started.

1. Create a Service Bus Project.




Give a suitable name and click on Finish.


2. Create folders - BusinessService, ProxyService, Resources. Under Resources folder, Create WSDL and XSD folders as below. You can also create a folder for Pipeline if you want.




Create an xsd file with request as two numbers and response as a result element.




Now, create a WSDL with four operations - Add, Sub, Mul, Div. Usually, we get WSDL files in business requirements. For testing purpose, I created a WSDL as below.





3. Create a Proxy Service with above WSDL. The proxy Service should look something like below.




If you don't get the error in Proxy as above, skip to the next step. If you get the cross mark on Proxy service, double click on the Proxy and click on Operation Selection. Change the Algorithm from 'SOAP Header' to 'SOAP Action Header' as below and save it. Now you won't see any errors on Proxy Service.





4. Edit the Pipeline, Drag and drop an Operational Branch. By default, it would look like below with Add branch that is selected with Add operation.




Add three more sub branches and select the operations Sub, Mul and Div respectively.





Now, insert a Pipeline Pair in the Add branch. Drag and drop a Replace activity into the Response pipeline.





Click on the Replace activity to give required values as below.




Remember to select the Num1 and Num2 elements from Add Operation in the XPath Expression Builder.





Similarly, add pipeline pairs into Sub, Mul and Div branches. Add a replace activity in each response pipeline and give the required values for Replace as we've done in Add branch but the Num1 and Num2 should be selected from their respective operations.

Note: For Division logic, give 'div' instead of '/'.

5. Finally your pipeline should look something like below.




Now, deploy and test your service:)

Friday, July 10, 2020

Java Callout in OSB 12c

In this post, I will show you how to create a simple java callout in OSB that adds up two numbers.

1. Create a Service bus project with the name 'JavaCallout'.




Click on Finish.

2. Now create a proxy service.




Check the checkbox 'Generate Pipeline'. Click on Next.




Select Service Type as 'Any XML' and click Next and then Finish.

3. Double click on the pipeline. Drag and drop a pipeline pair.




Now, drag and drop a Java Callout activity in the request pipeline. 




Select the jar file in the Method value. In my case, I'm selecting a jar file which contains the java class to add two numbers. The code of the Java class is as below for your reference:




Now, give the Expression for the int variables under Arguments. As I used the type of both variables as int, it is showing me as int in Arguments section.




Give the values as below:

For the first int variable: xs:int($body/*:result/*:Num1)
For the second int variable: xs:int($body/*:result/*:Num2)
Return variable: Result

4. Now, drag and drop a Replace activity in the response pipeline.




Select the values as below:

Location: body
XPath value: . ('.' represents the current node)
Value: $Result
Replace option: Replace node contents




Here, $Result is the variable that we assigned output to in Java Callout.

6. We've done with all the steps. Now, deploy the project into OSB server and click on the Proxy service or pipeline to test the service. Give the input in XML as below:

<result>
<Num1>18</Num1>
<Num2>45</Num2>
</result>

Of course, you can give any numbers that you want. Cheers!!

Thursday, July 9, 2020

Hello World Demo in Oracle OSB

This post shows how to create a simple hello world demo using service bus project in OSB Application.

1. Create a new service bus project in service bus application. If the application is not created, create a new OSB application (Click New>Service bus application).
Click on New>From Gallery>Service bus Project.



Give a name to the Project and click on Finish.


2. Drag and drop a pipeline from the Components section. Change the name if you want to and click Next.



 In the next screen, select WSDL and click on 'Create a WSDL' icon to create one.



3. In the WSDL screen, select the Interface type as Synchronous Interface as below.


Now, click on the '+' icon under Input.


Change the Part Name if you want to change and click on the magnifier icon in URL field to select the type. You can also choose this using xsd file but I've given it manually without creating the schema to keep it simple.


Expand XML Schema Simple Types and select string as type. Then Click OK. Do the same for Output variable and click OK in the WSDL screen.


4. Check 'the checkbox Expose as a Proxy Service' and then click Finish.



Your composite would look like this.




5. Double click on the Pipeline. You'll see a pipeline like below.



Drag and drop a Pipeline Pair from the Components. Add a Replace activity in the response pipeline as below.


Click on the Replace and add values as below.

location: "'body
XPath Expression: . ("." represents curent node)
Value: concat('Hello ', $body/hel:string)
Replace option: Replace node contents.





6. Now that we have done with creating a sample hello world project, save the project and deploy the project to the OSB server. For deployment, right click on the project, select deploy option.



Select osb server and and Finish.

Now go to service bus console page and click on the pipeline or proxy service of the project to test it.

Cheers!!



Featured Posts

Sample Real Time Assignment in Oracle SOA