This tutorial explains how OSB’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
- Canonical schema in Proxy Services
- Dynamic Routing to Business Services
- XML content transformation from canonical to native format
- XML content transformation to canonical from native format
- Routing Actions
We are going to invoke two public calculator webservices from Parasoft and Orafmwschool using following WSDLs:
- http://soaptest.parasoft.com/calculator.wsdl
- 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.
Create a new project named “calculator” using Project Explorer.
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.
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.
Similarly, create Orafmwschool Business Service using Orafmwschool Native Webservice we created earlier.
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”.
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:
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.
- 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.
- Transform request from Proxy Service’s canonical format to appropriate Business Service format.
- 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.
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.
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.
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.
Click on Save to return to Stage Configuration screen. Select operator “>” and provide value “1000” under Routing Table.
Click on <Service> link and select “ParasoftBS” from list of values. Select operation “multiply”.
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.
Enter “body” in variable field. Click on “XPath” link. Enter “./*” in XPath Expression.
Click on Save to return to main screen. Click on “Expression” link. Navigate to “XLST Resources” tab. Click on Browse and select ParasoftXSL component.
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.
Click on Save to return to Stage Configuration screen. Follow the same steps for Response Actions. Select ParasoftResponseXSL for XSLT file.
Click on case icon and insert a “Default Case”.
Follow above steps to
- Route service to OrafmwschoolBS,
- Add Request Action to transform input XML using OrafmwschoolRequestXSL.
- Add Response Action to transform output XML using OrafmwschoolResponseXSL.
Routing table now looks as below:
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.
Enter a value greater than 1000 for inputX field and hit “Execute”.
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.
If we run the proxy service with inputX=11, inputY=11, we can see the request routed to “OrafmwschoolBS”.
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?
Hi, I believe you are referring to
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.
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.
Suraj, thanks for pointing it out. I’ve hosted a new calculator webservice on our server and updated the article accordingly.
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.
I’ve tried it locally today. It works fine. Please verify whether you’ve specified correct filter criterion in the Routing Table.
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.
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.
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
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.
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
Thanks,
It’s ok. I access to the wsdl… sorry for the useless post.
No… Sorry it’s till the same story. I can’t download this wsdl…