Archive for the 'OSB' Category



Service Bus 12c – Error Handling

In this post, you will learn to do Error Handling and will incorporate in the Pipeline Template created in post.  We consider our Pipeline to return generic Fault response with error message in all possible error scenarios.

As you know, service provider can send error to consumer in following ways:

  • As a normal response, by populating fields like “ErrorNumber” and “ErrorMesssage” (assuming that these fields are defined in response message of operation in WSDL).
  • As a SOAP fault

Typically when Service Bus is mediating, you might have to transform Error or Fault response to the Fault structure defined in WSDL. For this, you need to understand Message Context Variables that can be used.

As per WS-I BP, the service provider should send the HTTP response code as 200 when the error is sent as normal response and 500 should be sent when the error is sent as SOAP fault.

In message flow, Error Handler can be defined for Stage node, Pipeline Pair node (both Request Pipeline and Response Pipeline individually), Routing node and for entire Pipeline (called Service Error Handler). When HTTP response code 200 is received, Service Bus treats it as a normal response and proceeds further with message flow. When response code 500 is received, Service Bus runtime control goes to Service Error Handler if it exists or any other low level Error Handlers depending on where you received. That means Service Bus treats even Fault response as normal response when HTTP response code is 200.

Service Bus populates different message context variables with error/fault messages and is accessible in Error Handler depending on whether you used Routing or Service Callout. The following table summarizes this discussion:

Activity

Scenario

Context Variable

Routing

Raise Error activity

$fault

Routing

Fault Response from business service

$body

Routing

System fault while calling business service

$fault

Service Callout

Raise Error activity

$fault

Service Callout

Fault Response from business service

$fault

Service Callout

System fault while calling business service

$fault

So there is a possibility of 3 context variables $body, $fault and $faultVar having Error or Fault information (assuming faultVar is variable used in Raise Error activity of your message flow).

With this background, let us get back to Pipeline Template to add required Error Handler. Since your Pipeline uses both Service Callout and Routing in message flow, you can do fault handling in the following manner in Pipeline Template so that all of your concrete pipelines using this template would inherit this automatically.

  • Add Service Error Handler.
  • Add conditional branches in error handler to verify $body is populated with SOAP Fault, or faultVar or $fault is populated. Based on this, you have to extract Error Code and Error Message from $body, $faultVar and $fault variables.
  • Populate $body variable with the Fault structure as defined in WSDL.
 
Changes in CustomerPipelineTemplate:

Drag If-Then activity into ErrorHandler stage from Flow Control and add 3 conditional branches (Else If branch) as shown below.

clip_image002

In Properties tab, set Condition for all branches in Expression Builder as shown below. Remember adding the namespace http://www.bea.com/wli/sb/stages/transform/config with con1 as alias in Namespaces.

Branch

Condition

Purpose

If

not(fn:empty($body/soap-env:Fault))

To handle fault received in Routing.

Else If

not(fn:empty($faultVar))

To handle error response from given in Raise Error activity.

Else If

not(fn:empty($fault/ctx:details/con1:ReceivedFaultDetail))

To handle fault received in Service Callout or Raise Error cases.

Else

-NA-

All other cases.

Drag Replace activity from Message Processing into each of these branches and set properties as shown below.

clip_image003

Set expression in Expression Builder with following SOAP Fault structure for Replace activity in If branch. Here you are extracting Error Code and Error Message from received SOAP fault received in Routing. This way you are forwarding the actual error from Service Provider to Consumer.

<soap-env:Fault>

<faultcode>env:Server</faultcode>

<faultstring>{$body/soap-env:Fault/faultstring/text()}</faultstring>

<detail>

<cust:ErrorStatusMsg xmlns:cust="http://xmlns.xyzbank.com/schema/Customer"&gt;

<ErrorCode>{$body/soap-env:Fault/faultcode/text()}</ErrorCode>

<ErrorMsg>{$body/soap-env:Fault/faultstring/text()}</ErrorMsg>

</cust:ErrorStatusMsg>

</detail>

</soap-env:Fault>

Set expression in Expression Builder with following SOAP Fault structure for Replace activity in Else If branch. Here you are extracting Error Code and Error Message used in Raise Error activity. Observe the usage of $fault variable to get error code given in RaiseError activity. This way you are forwarding the error message used in Raise Error activity to Consumer.

<soap-env:Fault>

<faultcode>env:Server</faultcode>

<faultstring>{$faultVar/error_message/text()}</faultstring>

<detail>

<cust:ErrorStatusMsg xmlns:cust="http://xmlns.xyzbank.com/schema/Customer"&gt;

<ErrorCode>{$fault/ctx:errorCode/text()}</ErrorCode>

<ErrorMsg>{$faultVar/error_message/text()}</ErrorMsg>

</cust:ErrorStatusMsg>

</detail>

</soap-env:Fault>

Set expression in Expression Builder with following SOAP Fault structure for Replace activity in second Else If branch. Here you are extracting Error Code and Error Message from SOAP Fault received in Service Callout. This way you are forwarding actual error from Service Provider to Consumer.

<soap-env:Fault>

<faultcode>env:Server</faultcode>

<faultstring>{$fault/ctx:reason/text()}</faultstring>

<detail>

<cust:ErrorStatusMsg xmlns:cust="http://xmlns.xyzbank.com/schema/Customer"&gt;

<ErrorCode>{$fault/ctx:details/con1:ReceivedFaultDetail/con1:faultcode/text()}</ErrorCode>

<ErrorMsg>{$fault/ctx:details/con1:ReceivedFaultDetail/con1:faultstring/text()}</ErrorMsg>

</cust:ErrorStatusMsg>

</detail>

</soap-env:Fault>

Set expression in Expression Builder with following SOAP fault structure for Replace activity in Else branch. Here you are extracting Error Code and Error Message from $fault to take care of other possible error scenarios.

<soap-env:Fault>

<faultcode>env:Server</faultcode>

<faultstring>{$fault/ctx:reason/text()}</faultstring>

<detail>

<cust:ErrorStatusMsg xmlns:cust="http://xmlns.xyzbank.com/schema/Customer"&gt;

<ErrorCode>{$fault/ctx:errorCode/text()}</ErrorCode>

<ErrorMsg>{$fault/ctx:reason/text()}</ErrorMsg>

</cust:ErrorStatusMsg>

</detail>

</soap-env:Fault>

Now drag Reply activity into ErrorHandler stage from Flow Control after If-then. In Properties tab, select property as With Failure. This would send HTTP response code as 500 along with SOAP fault. Selecting With Success will send HTTP response code as 200.

clip_image005

Alternatively, you can come up with a XQuery map accepting these parameters and return appropriate SOAP fault structure. Now your ErrorHandler stage should look like below.

clip_image007

Observe that the Proxy Service you created using this Pipeline Template in this post had inherited ErrorHandler stage as shown below.

clip_image009

Some times, you may want to give your specific messages or override the messages from Service Provider. You can make all this kind of changes in your Error Handler and also typically one would want to convert System Errors into generic Application Error before sending to Proxy Service consumer. You can find more about details element in $fault variable here.

Testing:

Run your Pipeline and observe Flow Trace and Variables as shown below. Observe that the Error response from your Pipeline always contains a SOAP Fault conforming to WSDL.

Following are a few of the screenshots showing different Fault responses for both Routing and Service Callout in different error scenarios.

System Error in Routing:

clip_image013

Error Response received in Routing:

clip_image015

Fault Response received in Routing:

clip_image017

Validate activity failure Error:

clip_image019

System Error received in Service Callout:

clip_image023

Error Response received in Service Callout:

clip_image024

Fault Response received in Service Callout:

clip_image026

Service Bus 12c – Securing Proxy Services

Security is one of the main aspects while developing any service and is no different from our regular web applications. Also services are reusable and can be invoked by either internal or external customers, so you should consider securing your Service Bus Proxy Services so that only valid users can invoke.

Service Bus is completely integrated with Oracle Webservices Manager (OWSM) that provides several out of the box security policies. You can use any of these OWSM policies to secure your Proxy Services based on requirements. Here in this post, you will use oracle/wss_username_token_service_policy policy to secure Proxy Service.

As a first step, you need to create users who can invoke the service. Typically an Organization will have users in LDAP directory and you have to configure one of the Authenticators in Weblogic server to access LDAP for authentication purpose. This configuration will not be discussed here in this post.

Creating User:

Login to Admin Console and click Security Realms in Domain Structure.

clip_image002

Click myrealm as shown below.

clip_image004

Navigate to Users by clicking on Users and Groups tab.

clip_image005

Click New and enter credentials as shown below.

clip_image007

Click OK. Observe that new user has been created which  can be used to invoke Proxy Service.

clip_image009

Attaching OWSM Policy:

Open your Proxy Service. Navigate to Policies tab and select option as shown below.

clip_image011

Click + icon in Security section and select policy oracle/wss_username_token_service_policy.

clip_image013

Click OK and observe that selected policy is shown up in Security section.

clip_image015

You can also attach OWSM policies to Proxy Service in sbconsole. Launch sbconsole and create a new session. Navigate to All Projects –> <<your project>> and open the Proxy service to bring up a new tab as shown below.

clip_image017

Click Security and choose the option as shown below.

clip_image019

Click Attach Policies icon (highlighted above) and select the policy as shown below and click Attach.

clip_image021

Click OK and observe that selected policy is shown up as shown below.

clip_image023

Save your changes in current tab and activate the session.

clip_image024

Testing

You can use SOAP UI for testing. Create a test suite in SOAP UI using your proxy service WSDL. Refer to http://soapui.org for any additional help.

Open request editor for any of your Proxy Service operations and paste the following in SOAP header. This represents the WS-Security header and is expected by OWSM policy i.e. attached to Proxy Service. You can observe username and password fields below.

<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt;

<wsse:UsernameToken>

<wsse:Username>UNAME1</wsse:Username>

<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Welcome1</wsse:Password&gt;

</wsse:UsernameToken>

</wsse:Security>

clip_image026

Test using wrong credentials and observe the output showing security error.

clip_image028

Test using credentials created in previous section and observe the output.

clip_image030

clip_image032

Service Bus 12c–Creating Static Split-Join

In this post, you will learn to create and use Split Join and will use the same XYZCustomer project used in previous posts.

Split Join allows you to split the request payload so that you can call multiple services concurrently as opposed to the sequential processing. This way, you will achieve improved service performance.

In this post, you use Split Join to aggregate Customer Information by invoking different business services in parallel. The Customer Information includes basic Customer Details, Orders and Accounts. You can create the business services using the WSDLs given below. Make sure that you create 3 business services named CustomerServiceBS, CustomerOrderServiceBS and CustomerAccountServiceBS using following WSDLs respectively.

Purpose

Service WSDL

Customer Object operations

CustomerService.wsdl

Customer Order operations

CustomerOrderService.wsdl

Customer Account operations

CustomerAccountService.wsdl

Split Join can only be created based on WSDL so create new WSDL in WSDLs folder, having single operation with following. You can get the WSDL used in this post from .

  • Customer ID as input.
  • Customer information including Customer, Orders and Accounts Info as output.

Copy CustMigrationSplitJoin.wsdl into WSDLs folder of XYZCustomer project from here and create a new folder SplitJoins as shown below.

clip_image002

Creating Split-Join:

Open Service Bus overview editor and drag Split Join into middle swim lane from Components -> Service Bus -> Resources and finish the creation using wizard as shown below. Make sure that you select SplitJoins folder as the location in wizard.

clip_image004

clip_image006

Click Next and select WSDL CustMigrationSplitJoin.wsdl.

clip_image008

Click OK and uncheck Expose as a Proxy Service.

clip_image010

Click Finish. Observe that your Split Join flow should look like below.

clip_image013

Drag Parallel activity after Receive as shown below from Flow Control and add another branch by clickingclip_image014. The Parallel activity allows you to invoke different services concurrently.

clip_image016

In Properties tab, modify Name for all the Scope activities as shown below. Drag Invoke Service activity into each of these Scope activities in all 3 parallel branches from Communication to invoke Business services. Also modify Name property for Invoke activities in Properties tab.

clip_image018

In Properties tab, browse and select CustomerServiceBS, CustomerOrderServiceBS and CustomerAccountServiceBS for Service property of InvokeCustomer, InvokeCustOrder, InvokeCustAccount activities respectively.

clip_image020

clip_image022

Select Operation as shown below for InvokeCustomer, InvokeCustOrder , InvokeCustAccount activities respectively.

clip_image024

clip_image026

clip_image028

For InvokeCustomer, create Request and Response variables as shown below. Request Variable can be created as local variable as you don’t use it outside the scope.

clip_image030

clip_image031

clip_image033

clip_image034

Now your properties tab for InvokeCustomer should look like below.

clip_image035

Similarly create variables CustOrderReq, CustOrderResp for InvokeCustOrder and CustAccReq, CustAccResp for InvokeCustAccount respectively. Local variables created for each Scope activity should look like below.

clip_image037

Your global variables would be shown at Split Join level.

clip_image039

Drag Assign activity from Assign Operations into each of the scope activity and name them as AssignCustInfoReq, AssignCustOrderReq and AssignCustAccReq respectively in Properties tab.

clip_image041

In Properties tab, set properties for AssignCustInfoReq as shown below. This populates request variable with payload for CustomerServiceBS. Since there are not many fields to map, we have chosen this way to populate the payload avoiding new transformations.

Value:

<cust:customerid_input xmlns:cust="urn:xyzbank:cust:schema:customer">

<customer_id>{$request.parameters/customer_id/text()}</customer_id>

</cust:customerid_input>

clip_image042

In Properties tab, set properties for AssignCustOrderReq as shown below. This populates request variable with payload for CustomeOrderServiceBS.

Value:

<ordr:order_input xmlns:ordr="urn:xyzbank:cust:schema:order">

<ordr:customer_id>{$request.parameters/customer_id/text()}</ordr:customer_id>

</ordr:order_input>

clip_image044

In Properties tab, set properties for AssignCustAccReq as shown below. This populates request variable with  payload for CustomeAccountServiceBS.

Value:

<acc:account_input xmlns:acc="urn:xyzbank:cust:schema:account">

<acc:customer_id>{$request.parameters/customer_id/text()}</acc:customer_id>

</acc:account_input>

clip_image045

This would fetch Customer, Order and Account information concurrently by invoking respective business services. And you have to aggregate all these responses before returning back to caller. So you need a transformation to do this.

Create a XQuery map in XQueries folder of XYZCustomer project as shown below. Give name as CustOrderAccountToCustInfo.xqy.

clip_image047

Choose the Source for XQuery map using steps shown below.

clip_image049

clip_image051

clip_image053

clip_image055

clip_image057

Go back to Create XQuery Map window by clicking OK twice.

clip_image059

Similarly add 2 more parameters as shown below to accept Account and Orders information as the input.

clip_image061

clip_image062

clip_image064

clip_image066

Your Create XQuery Map screen should look like below.

clip_image067

Select Target using steps mentioned below.

clip_image068

clip_image070

Click OK twice to finish XQuery map creation and should be visible in XQueries folder as shown below.

clip_image071

Observe the Sources and Target structures and finish the mapping as required and as shown below.  You may want to test your XQuery map using the steps mentioned in this post.

clip_image073

Next step is using this XQuery map in Split Join. Drag Assign after Parallel activity from Assign Operations and set properties as shown below.

clip_image074

clip_image075

clip_image077

clip_image079

clip_image081

With this, you are done with message flow for Split Join and let us finish error handling as well before proceeding with testing. The WSDL used for split join has generic fault structure and you will use the same structure to return all types of faults to caller. So we will do fault handling at Split Join level. Right click CustMigrationSplitJoin and select CatchAll as shown below.

clip_image083

clip_image085

In Properties tab, give the fault variable name as shown below.

clip_image087

Drag Reply activity into Catch All branch from Communication.

clip_image088

In Properties tab, set properties as shown below by creating the new fault variable. This enables Split Join to return fault in case of any error to Pipeline.

clip_image089

Drag Assign activity into Catch All branch before Reply activity from Assign Operations. Modify name to AssignFault and set properties as shown below.

Value:

<custinfo:fault_msg xmlns:custinfo="urn:xyzbank:cust:schema:customerinfo">

<custinfo:error_code>XYZ-0009</custinfo:error_code>

<custinfo:error_message>Error in join operation.</custinfo:error_message>

</custinfo:fault_msg>

clip_image090

Testing Split Join:

Test your Split Join in similar to Proxy service/Pipeline. For my testing, I have used SOAP UI Mock Service to send sample responses to Split Join.

clip_image091

Positive Case:

clip_image093

clip_image095

clip_image097

clip_image099

Negative Case:

clip_image101

Invoking Split Join:

Drag Stage into Request Pipeline of your message flow and set the name as CallSplitJoin. Drag Service Callout from Communication as shown below.

clip_image001

In Properties tab, browse and select CustMigrationSplitJoin for Service property.

clip_image003

Select GetCustomerInfo operation and set other properties of Service Callout as shown below.

clip_image005

sJoinReq is variable to be populated with the payload for GetCustomerInfo operation and sJoinResp is variable that contains response returned by split join after service call. Since you are using ‘Configure Payload Document‘ option, you just need to populate the request variable with required payload.

Drag Assign activity from Message Processing into Request Action of Service Callout and set properties as shown below.

Value:

<urn:customerid_input xmlns:urn="urn:xyzbank:cust:schema:customerinfo">

<customer_id>{$body/cus:CustomerIDInput/CustomerID/text()}</customer_id>

</urn:customerid_input>

clip_image007

Now your CallSplitJoin stage should look like below.

clip_image008[4]

Service Bus 12c – Using XSL map

In this post, you will learn to create and use XSL maps in message flow using the same Service Bus project used in previous posts.

clip_image002[4]_thumb[2]

And here we are creating XSLT map for Customer transformation. The Source WSDL CustomerPS.wsdl and Target WSDL CustomerService.wsdl  are available here and here respectively. Make sure that you have these WSDLs copied in your project before proceeding with XSL map creation.

Creating XSL map:

Right click XSLTs folder in XYZCustomer project and select New -> XSL Map and give File Name as CustomerPSToUpdateCustomer.

clip_image001

Click Browse for Primary Source to bring up Select Schema screen.

clip_image003

Retain default selection and click Browse to select the source element.

clip_image004

Click OK twice to go back to Create XSL Map screen. Now click Browse for Target to bring up Select Schema screen again. And click Browse for Select Schema and select the target element as shown below.

clip_image006

Click OK twice and observe Source and Target elements.

clip_image008

Click OK to finish that brings up XSLT Transformation editor as shown below.

clip_image010

Here we are planning to do update of Customer Information, so you should not send null values in payload to business service; hence Target elements should be mapped only when corresponding Source element is available.

You can achieve this behavior automatically in XSL Map editor by setting a preference. Go to Tools -> Preferences and set property as shown below.

clip_image012

Now go back to XSL Map editor and do the initial mapping as shown below by connecting respective Source and Target elements. Observe that xsl:if condition gets added automatically when source element is defined as optional in schema.

clip_image014

Drag concat function into middle swim lane from Components-> General XPath -> String Functions to concatenate FirstName, Lastame and map to full_name. Also concatenate State, Country and ZipCode and map to addr_line4 as shown below.

clip_image016

Click concat functions and modify them to add  ‘,’ between elements as shown below.

clip_image018

clip_image020

Now go to Source and modify full_name and addr_line4 elements mapping to include xsl:if conditions so that Target will be mapped only when all of the  corresponding Source elements are present.

clip_image022

clip_image024

Testing XSL map:

It’s always advisable to test your XSL map to see whether mapping is working as expected. Click Test XSL Map icon in editor to bring up the following screen.

clip_image026

Click OK and observe that mapping is working as expected as shown below. You can also verify that both Source and Target xml files are generated. You can modify source xml and retest your XSL map again.

clip_image028

Using XSL map in Message Flow:

Drag Replace activity from Message Processing into message flow at place wherever you require transformation. In Properties tab, bring up expression editor for Value property and choose XSL map as shown below.

clip_image030

clip_image032

Click OK and give Input Document Expression as $body/*.

clip_image034

Set other properties as shown below. This action will replace the contents of $body context variable with transformed payload.

clip_image036

Service Bus 12c – Using XQuery map

In this post, you will learn to create and use XQuery maps in message flow using the same Service Bus project used in previous posts.

clip_image002[4]

And here we are creating XQuery map for Address transformation. The Source WSDL CustomerPS.wsdl and Target WSDL AddrValidationService.wsdl  are available here and here respectively. Make sure that you have these WSDLs copied in your project before proceeding with XQuery map creation.

Creating XQuery map:

Right click XQueries folder in XYZCustomer project and select New -> XQuery File ver1.0 to create new XQuery. Give both file and function name as AddrToAddrBSInput as shown below.

clip_image002

Click + icon to add Source parameter and give name as inputAddr.

clip_image004

Click pencil icon for Sequence Type to bring up Function Parameter Type window. Click browse icon and select Customer element in CustomerPS.wsdl as shown below. Here Customer element has address fields.

clip_image006

Click OK and retain default values for all the other properties in Function Parameter Type window as shown below.

clip_image008

Go back to Create XQuery Map window by clicking OK twice. Now click pencil icon for Target to bring up Function Result Type window. Click browse icon and select addrval_input element as shown below. Observe that the WSDL being used is AddrValidationService.wsdl.

clip_image010

Click OK thrice to bring up the Transformation editor and also do the initial mapping of attributes as shown below. You can map the fields by connecting Source and Target elements directly.

clip_image012

Drag concat function from Components -> XQuery Functions -> String Functions into Mappings swim lane. Connect Address2 and Address3 input elements to this function as shown below, as Target element expects concatenation of all address lines.

clip_image014

Address Validation service expects address lines with ‘,’ as delimiter, so go to XQuery Source tab and modify concat function as shown below.

clip_image016

Testing XQuery map:

It’s always advisable to test your XQuery to verify that mapping is working as expected. So right click XQuery file in XYZCustomer project and select Run XQuery.

clip_image017

clip_image019

Click List of variables button (highlighted above) to bring Edit Variable screen and select options as shown below.  This will generate the sample inputs automatically.

clip_image021

Click save icon and give file name as SampleCustomerInput.xml and click Add to Sequence.

clip_image023

Click OK and go back to Run XQuery screen. Give Target file name as AddrServiceInput by clicking Save icon.

clip_image025

Click Run and verify output of XQuery map to see mapping is working as you expected. You can observe that all address elements in Source concatenated and assigned to single element address_line in Target. You can also verify sample Source and Target files created in your XQueries folder.

clip_image027

Using XQuery map:

Drag Assign activity into Service Callout from Message Processing or place it at any other place in your Message Flow depending on where you want to use this transformation.

clip_image029

In Properties tab, select XQuery Resources for Value property.

clip_image031

In Expression Builder, click Browse icon and select the XQuery mapping.

clip_image033

Click OK. Use the following steps to set value for Binding property.

clip_image035

clip_image037

Click OK twice and set addrReqBody as the value for Variable property. This variable will contain the transformed value of address and can be used in your message flow later.

clip_image039

Service Bus 12c – Using Domain Value Maps (DVM)

In this post, you will learn to use Domain Value Maps (DVM) in message flow.

We consider the business requirement of performing Address Validation in message flow based on a configurable property and we use DVM to store this Configurable Property.

Creating Domain Value Map (DVM)

Create a new folder named DVM in XYZCustomer project. Right click DVM folder and select New -> Domain Value Map.

clip_image001 

Give Config as File Name and give DVM entries as shown below. The domain name PropertyName represents Configurable Properties and the domain PropertyValue represents configurable property values respectively.

Using this DVM, you can extend the same logic to any number of configurable properties in your Service Bus Application. For our requirement, give property name as ValidateAddress and set it’s initial value as Y.

clip_image003

Click OK to bring up DVM editor.

clip_image005

You can use JDeveloper to modify DVM or you can also modify it in sbconsole. Remember you need to create a session before modifying anything.

clip_image007

Using DVM in Message Flow

Drag Stage node into Stages placeholder of Request Pipeline and set name as AddrValidation in Properties tab.

clip_image009

Drag Assign activity into AddrValidation stage from Message Processing. Bring up expression builder for Value property and give expression as shown below. Alternatively you can select the function from Functions -> Custom XPath Functions -> Dvm functions. Make sure that you give complete qualified path of DVM containing Service Bus Project name too.

clip_image011

Set Variable property as ConfigVar. Now your Properties tab should look like below.

clip_image013

Address Validation business service should be invoked only when the value of this configuration property ‘Y’. So drag If Then activity into AddrValidation stage after Assign from Flow Control and set condition as $ConfigVar=’Y’.

clip_image015

Service Bus provides Service Callout, Routing and Publish activities to route incoming request to an appropriate business service. Routing and Service Callout are used for Synchronous where as Publish activity is used for one-way communication.

Routing node always depicts end of message flow so you can’t place any activities after Routing node. Hence use Service Callout for all intermediate service calls in pipeline. Drag Service Callout from Communication into If Then branch as shown below.

clip_image017

In Properties tab, browse and select AddrValidationServiceBS for Service property.

clip_image019

Service Bus 12c–Creating Proxy Service using Pipeline Template

In this post, you will learn to create Pipeline and expose it as Proxy Service using Pipeline Template created in previous post.

You need a WSDL to be used in Proxy Service and you can get the one used in this post from here. You can copy WSDL into any of your Service Bus project directory in file system directly. And click Refresh in Project Explorer so that these resources will be shown. We will use the following Projects.

clip_image002

Right click Pipelines folder and select New -> Pipeline.

clip_image004

Give name as CustomerPSPipeline and select the option From Template as shown below.

clip_image006

Click Search icon to bring up Resource Chooser and select Pipeline Template.

clip_image008

Click OK to go back to Create Pipeline Service window and click Next.

clip_image010

Click Browse WSDLs icon (highlighted above) and select CustomerPS.wsdl from XYZCustomer project as shown below and click OK.

clip_image012

Verify that WSDL and binding is selected. Click Search icon for Proxy Location and select ProxyServices folder as shown below.

clip_image014

Click Select and modify Proxy Name to CustomerPS. Now your Create Pipeline Service window should look like below.

clip_image016

Click Finish. Verify both Pipeline and Proxy Service are created in Pipelines and ProxyServices folders respectively as shown in Project Explorer.

clip_image018

Observe that new tab is opened showing CustomerPSPipeline had inherited all placeholders, names and properties from your Pipeline Template. You can modify/add activities in placeholders and the properties of inherited activities. Since a few of the properties to be specified mandatorily in concrete pipelines and are not mentioned in template, you will see red marks (see below) both in Project Explorer and editor.

clip_image020

Open CustomerPS and navigate to Transport configuration as shown below. Modify Endpoint URI as /entity/CustomerService. So your service consumers can access your proxy service using following URL:

http://<host>:<port>/entity/CustomerService

clip_image021

Go to Message Handling tab and select SOAPAction Header as Selection Algorithm. This would enable proxy service to determine operation at runtime based on SOAP Action sent in HTTP header. These changes should resolve errors in Proxy Service and you can observe that red marks are not seen now.

clip_image023

To resolve errors in Pipeline you should set the properties of Validate activity. In Properties tab of Validate activity, for Schema property click Search icon and select Customer element from proxy service WSDL as shown below. This would enable Service Bus validate input payload against the selected schema at runtime.

clip_image002[8]

For Location property, bring up expression editor by clicking iconclip_image003. Drag or shuttle Customer element into Expression field as shown below and click OK. Now you can observe that all red marks are gone for Pipeline as well.

clip_image005

Now your properties tab for Validate activity should look like below.

clip_image007

Now your Service Bus Overview Editor should look like below.

clip_image025

Service Bus 12c – Creating Pipeline Template

In this post, you will learn how to create Pipeline Templates in Service Bus 12c.

A Pipeline Template defines general shape or pattern of your message flow. We use Service Bus project XYZCustomer shown below for the demonstration purpose and we intended to create proxy service performing CRUD operations on objects like Customer.

clip_image002

Note: You can create new folders by navigating to File -> New -> From Gallery -> General -> Folder.

Right click Pipelines folder and select New -> Pipeline Template.

clip_image004

Give a meaningful name. Here we are using name CustomerPipelineTemplate.

 

clip_image006

 

Click Next. In this screen, you can choose service type depending on your requirement. Here we want to create WSDL based proxy service, so choose Service Type as WSDL SOAP as shown below.

clip_image008

Click Finish and verify that new Pipeline Template is created and opened in a separate tab as shown below.

clip_image010

Pipeline templates are the right candidates to keep common logic or enforce pattern of message flow to be followed across Proxy services. Typically, you may want to perform following common activities for different operations that your Proxy Service supports.

  • Validation of payload against schema
  • Routing to a business service (e.g: CustomerServiceBS)
  • Error Handling

Along with above functionality, your Pipeline Template needs to have nodes like Operational branch, Pipeline Pair, Stages etc…

When consumers call Proxy Service, it has to take different execution paths based on operation called. The Service Bus provides Operational Branch node serving this purpose. So drag Operational from Template Placeholders onto pipeline template where yellow circle is shown.

 

Note: All Nodes or activities used in message flow for Pipeline or Pipeline template are available in Components -> Message Flow under different sections. If you don’t see Components window, get it by selecting Window -> Components.

clip_image012

clip_image014

Click BranchNode1 and set name as CustomerOperation in Properties tab as shown below. As a best practice, always give meaningful labels for Nodes and other activities (wherever applicable).

clip_image016

Now drag Pipeline Pair from Nodes into Branch and give name as PipelinePair and rename Stage1 node in Request Pipeline to Validation in Properties tab.  Now your pipeline template should look like below.

clip_image018

Service Bus provides Validate activity to do payload validation against schema. So drag Validate activity into Validation stage from Message Processing.

clip_image020

In Properties tab, set Location property value as body and other properties as shown below. Here you will not select any schema or WSDL for validate activity as it’s just template and we will not have any payload available.

clip_image022

There may be additional validations to be performed while designing message flow in concrete Pipelines which requires a place holder. So drag Actions into Validation stage as shown below from Template Placeholders.

clip_image024

Delete Stage1 in Response Pipeline by selecting Delete option on right click. Also you may need to create several Stage nodes in your concrete Pipeline’s message flow. So create a place holder for the same in your template. Drag Stages into pipeline after Validation stage and in Response Pipeline from Template Placeholders. Now your pipeline pair node should look like below.

clip_image026

Routing node always depicts end of your message flow and you will not be able to place any other activities after this node. So drag and place Route after PipelinePair from Template Placeholders and set name as Route in Properties tab. Observe Actions placeholder which allows user to place any type of activity while designing message flow for your concrete pipelines.

clip_image028

Error handling is another aspect of message flow where you may want to follow similar approach for all Proxy Services. So drag Error Handler onto CustomerPipelineTemplate from Nodes. And in Properties tab, set name as ErrorHandler for Stage1 as shown below.

clip_image030

We will see Error Handling in detail in separate post. For the time being, you can drag Actions placeholder into ErrorHandler stage.

With this, you are done with Pipeline Template and can proceed with creation of Pipelines using this template.

Service Bus 12c – Deploying and Testing

During development, you may often deploy and test your Business and Proxy services to verify that you are able to send request and receive response as expected. And typically, if the service provider is external to your organization, you have to configure your business service to use HTTP proxy server.

Note: HTTP Proxy Server is a global resource to be created in Service Bus Application and can be attached to business service in Advanced Settings of Transport Details tab.

In Service Bus 12c, you can use either Integrated or Standalone WLS to test business/proxy services.

Integrated WLS:

Right click business/proxy service and select Run.

clip_image002

If Default Domain does not exist, JDeveloper will prompt for credentials to create Integrated WLS. Enter credentials click OK to start server.

clip_image004

Once the server starts, Test Console is opened as shown below. This Test Console shows all available operations (If it’s based on WSDL), Request Document section (to enter payload), Transport section (to enter transport headers) and Attachments section.

clip_image006

Click Execute and observe that you are able to send request and receive response as shown below. You can use Back to modify payload and repeat your test scenarios.

clip_image008

Standalone WLS:

You can also deploy your service bus project to standalone WLS from JDeveloper and test from sbconsole. Right click XYZCommon project and choose Deploy as shown below.

clip_image010

Finish deployment using steps shown below.

clip_image012

clip_image014

clip_image016

Once deployment is done, login to sbconsole using http://host:port/sbconsole. Clicking arrow icon (highlighted below) will bring up the same Test Console shown earlier.

clip_image018

Another option is exporting your projects as Configuration Jar and deploy to either Integrated or Standalone WLS. To do this, right click XYZCommon project and select Export as shown below.

clip_image019

Select Service Bus Resources option as shown below.

clip_image021

Select Configuration Jar as destination.

clip_image023

Click Next. Give Jar file name including file system path as shown below and click Finish.

clip_image025

Open sbconsle. Create new session by clicking Create to import configuration jar.

clip_image026

Click Import icon in Resources tab.

clip_image028

Select configuration jar using Choose File button as show below.

clip_image030

Click Next. Accept defaults and click Import.

clip_image032

Click Close on confirmation screen and verify new project is shown as below in Resources tab.

clip_image034

Click Activate and confirm the session so that your changes will be effective.

clip_image035

clip_image037

Similarly, you can export service bus project directly to server by choosing Server as shown below in Export Service Bus Resources window shown earlier.

clip_image039

Click Next and choose Destination Server as shown below.

clip_image041

Click Next. Accept defaults and click Finish. Once export is successful, you can launch sbconsole and test your business and proxy services as shown above.

clip_image043

Note: Developer can choose any of the above options for deploying and testing business/proxy services.

Service Bus 12c – Creating Business Services

In Service Bus, Business Services provide abstraction layer and take care of communication with Service Providers. In this post, you will see different ways of creating Business Service in Service Bus project using JDeveloper based on a WSDL. And for the demonstration purpose, we will consider the Service Bus project and WSDLs shown below.

biz1

Method 1:

Right click Service Bus project and select New -> Business Service.

clip_image002

Give a meaningful name for Business Service as shown below.

clip_image004

Click Browse WSDLs icon (shown above) and choose CustomerService WSDL as shown below.

clip_image006

Click OK to go back to Create Business Service wizard.

biz5

Method 2:

Open the Service Bus overview file (file with same name as your project) and drag HTTP adapter into from Components –> Service Bus –> Technology –> HTTP into External Services swim lane to bring up Create Business Service wizard as shown below.

adapter1

overview1

biz2

Give meaningful name for Business Service and click Next. Select the option WSDL and choose WSDL as shown in previous method by clicking Browse WSDLs icon.

biz3

biz4

Method 3:

Right click WSDL in Service Bus project and select Service Bus –> Generate Business Service as shown below.

wsdlbiz

Verify that Create Business Service wizard has come up showing WSDL and binding selected.

wsdlbiz1 

And the following steps are common irrespective of the above methods you choose to create Business Service.

Click Next and enter Endpoint URI of the service.

clip_image008

Click Finish to bring up a new tab showing CustomerServiceBS.bix.

clip_image010


Pages

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 196 other subscribers

Enter your email address to follow this blog and receive notifications of new posts by email.