OSB 12c - ServiceCallout

Here we go!
Information that you need to know:

The Service Callout component is used only to trigger Synchronous External Services, this component can invoke one or more Business Service(s) as part of message augmentation, enrichment or validation, but this is not the primary business service for a given Proxy, unlike the Route action.
The Service Callout can be equivalent to credit card validation, address verification while Route is equivalent to final order placement. There can be multiple Service Callouts inside a Proxy pipeline.

A Service Callout is not the actual target or end service for a Proxy Service in OSB. Its simply a service invocation to either modify, validate, transform, augment or enrich the incoming request or outgoing response within a Proxy execution.

Communication Actions

The following table describes the communication actions.

Action  Service Callout
Used to...  Configure a synchronous (blocking) callout to a
Service Bus-registered Proxy Service, Business Service,
pipeline or split-join
Available in 
  • Pipeline stage
  • Error handler stage
  • Route node
For more detailed information read the following URL: https://docs.oracle.com/middleware/1213/osb/develop/GUID-FE2CAC5B-E4DF-49DE-AD3C-36EEAF750BFE.htm#OSBDV2362

Constructing Service Callout Messages

When Service Bus makes a call to a service using a service callout action, the content of the message is constructed using the values of variables in the message context. The message content for outbound messages is handled differently depending upon the type of the target service.
How the message content is created depends on the type of the target service and whether you choose to configure the SOAP body or the payload (parameters or document), as described in the following topics:

  • SOAP Document Style Services
  • SOAP RPC Style Services
  • XML Services
  • Messaging Services

For more detailed information read the following URL: https://docs.oracle.com/middleware/1213/osb/develop/GUID-FE2CAC5B-E4DF-49DE-AD3C-36EEAF750BFE.htm#OSBDV2379

In this post, we will learn how create OSB Project with Service Callout component.

We need to start the JDeveloper IDE.

Click on File menu, then click on New option, followed immediately by Application option.

For example:

Then on the New Gallery window, choose Applications option in General Category, then choose Service Bus Application item.

For example:

On the Application window, set the next values, and click on finish button.
Application Name  TrainingOSB
Directory  C:\JDeveloper\mywork\Training\TrainingOSB
Application Package Prefix 

For example:

Click on File menu, then click on New option, followed immediately by Project option.

For example:

Then on the New Gallery window, choose Projects option in General Category, then choose Service Bus Project item.

For example:

On the Project window, set the next values, and click on next button.
Project Name  ServiceCallout
Directory  C:\JDeveloper\mywork\Training\TrainingOSB\ServiceCallout

For example:

After clicking on finish button, the JDeveloper IDE has the next appearance:

Then the next step, we need go to ServiceCallout directory and create the following folders (required in accordance with project standards (naming conventions)):

  • BusinessServices
  • ProxyServices
  • WSDLs
  • Schemas
  • Transformations
--> ProxyService folder to place/store/save the proxy services which ends with .proxy
--> BusinessService folder to place/store/save the Business Services which ends with .bix
--> WSDLs folder to store all required artifacts WSDL type
--> Schemas folder to store all required artifacts Schema type
--> Transformations folder to store all required artifacts Transformation type

For example:

Click on Refresh icon, then select Refresh Application, now we are going to view the folders that we created in the previous step.

For example:

We are going to create the XML schema, so for this we need to select the Schemas folder and right-click, then in the options of the pop-up list we must select New -> XML Schema...

Note: An XML Schema describes the structure of an XML document. The XML Schema language is also referred to as XML Schema Definition (XSD).

On Create XML Schema window, we need put the following values:

File Name  ServiceCallout
Directory  C:\JDeveloper\mywork\Training\TrainingOSB\ServiceCallout\Schemas
Target Namespace   
Prefix   

For example:

We need to update the XSD file with only two elements, these are process and processResponse both are string type.

For example:
Design
Source

The next step create a contract –> we will create new WSDL for contract with single input and single output, so for this we need to select the WSDLs folder and right-click, then in the options of the pop-up list we must select New -> WSDL (builder)...

For the Interface Type, choose "Synchronous Interface" from two options available –> which will enable the input, output and fault elements to be entered for inputs, outputs and faults respectively.

Basically the information entered in the Create WSDL window should be the following:

File Name  ServiceCallout.wsdl
Directory  C:\JDeveloper\mywork\Training\TrainingOSB\ServiceCallout\WSDLs
Namespace  http://xmlns.oracle.com/TrainingOSB/ServiceCallout/ServiceCallout
Binding  execute_bind
Binding Type  SOAP 1.2
Create Port Type  Selected
Port Type  execute_ptt
Operation  execute
Interface Type  Synchronous Interface
Input  Message Part Name: request
Output  Message Part Name: response
Fault   

Note: Click green plus icon to add the required elements for input, output and fault (on right-top-corner).

Click OK.

The WSDL have the following design.


Note: It may be of your interest, read about from SOAP 1.1 to SOAP 1.2 in the following URL: https://www.w3.org/2003/06/soap11-soap12

Then the next step, we need to create the Pipeline service, to do we need select the Pipeline component, this component is located on the right side, on Components section, when you found this, select it and drag it to Pipelines/Split Joins section on work area (canvas).

FOR YOUR INFORMATION: Pipelines define message routing and transformation logic, as well as message handling options. This logic includes activities such as transformation, publishing, logging, reporting, alerts, and exception management. Each of these activities are configured as individual actions within the message flow.

The following primary elements are used to construct a pipeline:

  • A start node.
  • A pipeline pair, one for the request and one for the response. Each pipeline in a pair consists of a sequence of stages that specify actions to perform during request or response processing.
  • A branch node, to branch based on the values in designated parts of the message or message context, or to branch based on the operation invoked.
  • A route node, to define the message destination. The default route node is an echo node that reflects the request as the response.
  • An error handler, which can be attached to any node or stage to handle potential errors at that location.

Then on Create Pipeline Service - Step 1 of 2, we are going to fill the fields according to the following table.

Service Name  ServiceCalloutPipeline
Location  C:\JDeveloper\mywork\Training\TrainingOSB\ServiceCallout\ProxyServices
Description   
From Template  Unchecked

For example:

Then on Create Pipeline Service - Step 2 of 2, we are going to fill the fields according to the following table.

WSDL  ServiceCallout/WSDLs/ServiceCallout
Binding  execute_bind
Expose as a Proxy Service  Checked
Proxy Name  ServiceCalloutPipelineProxyService
Proxy Location  C:\JDeveloper\mywork\Training\TrainingOSB\ServiceCallout\ProxyServices
Proxy Transport  http

Basically we are going to select the WSDL that we created previously, and check the Expose as a Proxy Service field.

For example:

FOR YOUR INFORMATION: Proxy services are Service Bus definitions of generic intermediary web services that are hosted locally on Service Bus. A proxy service communicates with external services through interfaces, which may or may not be identical to that of a service provider or service consumer Business Service. Through pipelines, you can route messages from a proxy service to multiple Business Services using their configured independent interfaces.

Once completed the previous steps, your JDeveloper should be the following appearance.

We are going to do double click on the ServiceCalloutPipeline component, right after, the ServiceCalloutPipeline.pipeline will open, as you can see in the following image.

Then we are going to locate the Pipeline Pair component, select it and drag it to the start node (below the ServiceCalloutPipeline service), having as a result the following appearance:

We are going to change the names of Stages, use the following table for your reference.

Stage1 (Request Pipeline -> RequestStage
Stage1 (Response Pipeline -> ResponseStage

For example:

Then we are going to locate the Service Callout component, select it and drag it to RequestStage node.

For example:

Now we are going to update the Service Callout component, but before that we need to create a REST Business Service, once completed this activity we are going to fill the Service Callout properties.

Note: If you need additional information about how create a REST Business Service click on the next URL: Create REST Business Service

Once time created the REST Business Service, as a first step, we must select the Service Callout component, with this action the Properties section should be displayed.

For example:


Now the next step is to click on Browse icon, then select the Business Service component, for this exercise the name I gave it is RestReference.bix, in Resource Chooser page select it.

For example:


So we need to update the Properties using as a reference the following table.

Service  ServiceCallout/BusinessService/RestReference.bix
Operation  GetTask * The operation name is the one you put when you created the REST Business Service
Configuration  Configure Payload Document
Request Payload  getRequest
Response Payload  getResponse

For example:

Then we are going to locate the Insert component, select it and drag it to Request Action node.

For example:

FOR YOUR INFORMATION:
Configuring Actions in Stages and Route Nodes
Actions provide instructions for handling messages in pipeline stages, error handler stages, and route nodes. The context determines which actions are available, as described in the following sections:

  • Communication Actions
  • Flow Control Actions
  • Message Processing Actions
  • Reporting Actions
Message Processing Actions
Action  Insert
Used to...  Insert the result of an XQuery or XSLT expression at an identified place relative to nodes selected by an XPath expression.
Available in 
  • Pipeline stage
  • Error handler stage
  • Route node
For more detailed information read the following URL: https://docs.oracle.com/middleware/1213/osb/develop/GUID-FE2CAC5B-E4DF-49DE-AD3C-36EEAF750BFE.htm#OSBDV2366

Adding Insert Actions
To add an insert action:

1. Navigate to where you want to add the action.
2. Click the appropriate icon, then select Add an Action > Message Processing > Insert.
3. Click Expression to edit an XQuery expression. The XQuery expression is used to create the data that will be inserted at a specified location in a named variable. The XQuery Expression Editor page is displayed.
4. When you finish editing the expression, select the relative location from the list. The relative location is used to control where the insert is performed relative to the result of the XPath expression.
* Before: As sibling before each element or attribute selected by the XPath expression.
* After: As sibling after each element or attribute selected by the XPath expression.
* As first child of: As first child of each element identified by the XPath expression. An error occurs if the result of the XPath returns attributes.
* As last child of: As last child of each element identified by the XPath expression. An error occurs if the XPath returns attributes.
5. Click XPath. The XPath Expression Editor page is displayed.
* XQuery and XPath expressions both return elements.
* The XQuery and XPath expressions both return attributes—in which case, the XQuery expression must return attributes.
6. When you finish editing the XPath expression, enter a context variable in the in variable field. The XPath evaluates the contents of this variable.

For more detailed information read the following URL: https://docs.oracle.com/middleware/1213/osb/develop/GUID-97AB0C09-A8CF-48CD-A173-C2A568B8A2DE.htm#OSBDV2503

To fill the Insert - Properties, use the following table as a reference.

Value (XQuery expression
Position (Relative location as first child of
Location  outbound
XPath  ./ctx:transport/ctx:request


For example:

Then we are going to locate the Assign component, select it and drag it to Response Action node.

Value  fn:replace($getResponse,'""',"null")
Variable  getResponse

For example:

In the next step we are going to locate the nSXD Translate component, select it and drag it to Response Action node.

Translate  Native to XML
Input  $getResponse
nXSD Schema  Static (ServiceCallout/Resources/RestReference.xsd)
Output  Variable (GetResponseXMLMsg)
Enforce Schema Order  Unchecked

For example:

Cheer up! We are almost done, as the penultimate step we are going to locate the Transport Header component, select it and drag it to Response Action node.

Direction  Inbound Response
Copy Headers  Unchecked
Headers  Set > Content-Type > "application/xml"

For example:

Once completed the previous steps the Pipeline should be have the following design.

For example:

The last step is create a jar configuration file to can deploy it on OSB Console.



Note: If you need additional information about how to do this activity, click on the following link .

Comments

Popular posts from this blog

SOA 12c - Fault Handling (Creating Fault Policies and Fault Bindings)

SOA 12c - DB Adapter (Poll for New or Changed Records in a Table)

SOA 12c - DB Adapter (Perform an Operation on a Table)