web analytics
free online training

Oracle Service Bus Routing and Transformation

OSB Routing Example

This tutorial explains how ’s dynamic routing and transformation features can be used to invoke two different public calculator web services.

At the end of this tutorial, you should understand

  1. Canonical schema in Proxy Services
  2. Dynamic Routing to Business Services
  3. XML content transformation from canonical to native format
  4. XML content transformation to canonical from native format
  5. Routing Actions

We are going to invoke two public calculator webservices from Parasoft and Orafmwschool using following WSDLs:

  1. http://soaptest.parasoft.com/calculator.wsdl
  2. http://orafmwschool.webhop.net:7001/CalculatorWS/CalculatorPort?WSDL

Each of these native webservices is invoked using a corresponding business service. Finally, we shall create a proxy service using canonical schema to invoke either of the business services based on specific routing conditions.

Login to OSB Console using url http://localhost:7001/sbconsole

Click “Create” in Change Center to create a new session.

image

Create a new project named “calculator” using Project Explorer.

image

Create “proxyservice”, “businessservice”, “extservice” folders in calculator project to hold proxy services, business services, external services respectively.

Import Native Webservices

Click on “extservice” folder link and import Parasoft and Orafmwschool WSDLs using Create Resource –> Interface WSDL option.

image

image

We have completed importing native webservices into extservice folder. Let us create business services to invoke these native services now.

Create Business Services

Click on “businessservice” folder. Using Create Resource –> Service –> Business Service command, create Business Service to invoke Parasoft Native Webservice. Select Parasoft WSDL we created in previous step for “WSDL Web Service” as shown below.

image

Similarly, create Orafmwschool Business Service using Orafmwschool Native Webservice we created earlier.

OSB Business Services

Create Proxy Service

Import XML artifacts necessary to create proxy service using details given below:

Name Type Description Command
ParasoftXSL XSLT file Convert canonical request to native parasoft webservice request Create Resource –> Transformation –> XSLT
OrafmwschoolRequestXSL XSLT file Convert canonical request to native Orafmwschool webservice request Create Resource –> Transformation –> XSLT
ParsoftResponseXSL XSLT file Convert native parasoft webservice response to canonical format Create Resource –> Transformation –> XSLT
OrafmwschoolResponseXSL XSLT file Convert native Orafmwschool webservice reseponse to canonical format Create Resource –> Transformation –> XSLT
Calculator.xsd XSD file Calculator canonical schema definiton Create Resource -> Interface ->XML Schema
CalculatorCanonicalWSDL WSDL file Abstract WSDL definition for proxy service Create Resource -> Interface ->WSDL

After importing CalculatorCanonicalWSDL, we need to explicitly set the reference to Calculator.xsd file. Click on CalculatorCanonicalWSDL link from Resource section. From “View a WSDL (calculator/proxyservice/CalculatorCanonicalWSDL)” page, click on “Edit References”.

image

image

Specify calculator/proxyservice/calculator.xsd for XML Schema Name.

Create CalculatorProxyService based on “CalculatorCanonicalWSDL“ using Create Resource –> Service –> Proxy Service command. Here is the summary of resource we created so far:

image

We have successfully imported native webservices, created business and proxy services to interface them. Now, we need to create routing between proxy services, business services and native webservices. We also need to transform data appropriately.

Create Routing & Transformation

We are going to perform following tasks in routing and transformation.

  1. Route the request to Parasoft Business Service in case input value X is more than 1000. Create a default case to route request to Orafmwschool Business Service.
  2. Transform request from Proxy Service’s canonical format to appropriate Business Service format.
  3. Transform response from Business Service back to Proxy Service’s canonical format.

Navigate to proxyservice folder under calculator project. Click on Edit Message Flow icon.

image

From Edit Message Flow screen, click on CalculatorProxyService and then “Add Route”. Click on “Route Node1” and select “Edit Route”. From Edit Stage Configuration screen, click on Add Action –> Communication –> Routing Table.

image image image

Route Node screen appears as below. Click on “Expression” link next to “Routing Table”. From next screen, click on Variable Structure link at the bottom left corner of the screen.

image image

From Structure drop down at the top left corner of the screen, navigate to $body –> calculatorRequest –> inputX. Corresponding XQuery expression will be displayed in the “Property Inspector” section. Copy this expression to the text area above “Property Inspector” section.

image

Click on Save to return to Stage Configuration screen. Select operator “>” and provide value “1000” under Routing Table.

image

Click on <Service> link and select “ParasoftBS” from list of values. Select operation “multiply”.

image

Lets transform XML data from canonical to native format now. Click on “Add an Action” link under “Request Actions” and select “Message Processing –> Replace” option.

image

Enter “body” in variable field. Click on “XPath” link. Enter “./*” in XPath Expression.

image

image

Click on Save to return to main screen. Click on “Expression” link. Navigate to “XLST Resources” tab. Click on Browse and select ParasoftXSL component.

image

image

Click “Submit” to return to XQuery/XSLT Expression Editor. In “Input Document” field enter “$body/*”. This makes sure Canonical request payload ($body) is transformed using ParasoftXSL.

image

Click on Save to return to Stage Configuration screen. Follow the same steps for Response Actions. Select ParasoftResponseXSL for XSLT file.

image

Click on case icon and insert a “Default Case”.

image

Follow above steps to

  1. Route service to OrafmwschoolBS,
  2. Add Request Action to transform input XML using OrafmwschoolRequestXSL.
  3. Add Response Action to transform output XML using OrafmwschoolResponseXSL.

Routing table now looks as below:

image

Click on Save to return to Message Flow screen. Click Save again to save proxy service and return to project dashboard.

From Change Center, click on “Activate” and “Submit” to save changes made so far.

Test Proxy Service

Launch Test Console using the icon next to CalculatorProxyService entry.

image

Enter a value greater than 1000 for inputX field and hit “Execute”.

image

We can see the multiplication value of 1001 x 11 = 11011.0 in the response XML. From “Invocation Trace” section, we can see that the request is sent to ParasoftBS.

image

If we run the proxy service with inputX=11, inputY=11, we can see the request routed to “OrafmwschoolBS”.

image

VN:F [1.9.17_1161]
Rating: 10.0/10 (2 votes cast)
VN:F [1.9.17_1161]
Rating: +1 (from 1 vote)
Oracle Service Bus Routing and Transformation, 10.0 out of 10 based on 2 ratings

Related posts

13 Comments
  1. the link which is pointing to reference services in wsdl files is invalid thats why when i am trying to debug webservice its says page not found can you tell me how to resolve this?

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
    • Hi, I believe you are referring to

      soapAction="http://orafmwschool.com/training/calculatorservice/service/multiply"/>

      The above code fragment, part of “CalculatorCanonicalWSDL” is used only for structure of input and output from proxy. Eventually, proxy service will invoke business services for Parasoft and ASPAlliance webservices. If you follow the steps explained in the article and still have problems, please admin@orafmwschool.com with relevant error messages and screenshots.

      VN:F [1.9.17_1161]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
    • I also tested the web-service from SOAP UI by changing the end point of the webservice to point to my local OSB Proxy service and it works for Parasoft Business Service and ASPAlliance Business Service. ASPAlliance web-service has issues, the endpoint does not seem to be valid anymore.

      VA:F [1.9.17_1161]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
      • Suraj, thanks for pointing it out. I’ve hosted a new calculator webservice on our server and updated the article accordingly.

        VN:F [1.9.17_1161]
        Rating: 0.0/5 (0 votes cast)
        VN:F [1.9.17_1161]
        Rating: 0 (from 0 votes)
  2. Looks like the ASPAllianceBS webservice does not work. When number is less than 1000.

    The other web-service for > 1000 works. I also tried to add a validate condition and reporting, report and log.

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
    • I’ve tried it locally today. It works fine. Please verify whether you’ve specified correct filter criterion in the Routing Table.

      VN:F [1.9.17_1161]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
  3. Hi,
    I was following this tutorial when i encountered this issues.

    1) The following wsdl file is missing. The page does not open up.

    http://aspalliance.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx?wsdl

    2)When we click the link for calculator.xsd for proxy services…a new page with the xsd code is opened. However, when we copy the xsd from that page and paste it in the XML SCHEMA file and click save…
    we get this error message “error: Use of undefined namespace prefix: xsd”

    Could you please tell us the correct namespaces to use.

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
    • Salil

      1) ASPAlliance webservice is no longer available. Hence, I’ve created a new webservice on our server and updated the article accordingly.
      2) Please view the source of XSD instead of copying content directly from HTML output. Source will have xmlns:xsd=”http://www.w3.org/2001/XMLSchema” definition.

      VN:F [1.9.17_1161]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
  4. Hi,

    I am unable to download the http://orafmwschool.webhop.net:7001/CalculatorWS/CalculatorPort?WSDL . The request was rejected (thats the browser error in IE as well as Google chrome) .

    pls do the needful.

    tks,
    gopi

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
    • This WSDL comes out from our training server which is used by training participants during training. We will email you once the server is available next time.

      VN:F [1.9.17_1161]
      Rating: 0.0/5 (0 votes cast)
      VN:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
  5. Hello,

    I’ve the same problem than Gopi, I can’t download the following wsdl : http://orafmwschool.webhop.net:7001/CalculatorWS/CalculatorPort?WSDL.

    Thanks,

    Sophie

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
  6. Thanks,

    It’s ok. I access to the wsdl… sorry for the useless post.

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.17_1161]
    Rating: 0 (from 0 votes)
    • No… Sorry it’s till the same story. I can’t download this wsdl…

      VA:F [1.9.17_1161]
      Rating: 0.0/5 (0 votes cast)
      VA:F [1.9.17_1161]
      Rating: 0 (from 0 votes)
Leave a Reply