Consuming a Web Service

This wiki article is a tutorial from a recent presentation/demo I gave at the Alliance 2010 Down Under Conference in Brisbane.

It takes you through the following:

  • Inspecting a web service using soapUI
  • Consuming a web service in PeopleSoft using the consume web service wizard
  • Creating a very simple pagelet with the pagelet wizard that uses the web service

Inspecting the Web Service

The web service we will be working with is a simple currency converter web service. The WSDL for this web service is available at
http://www.webservicex.com/CurrencyConvertor.asmx?wsdl

First thing is to check this web service is available in your browser, so visit the URL above and check you see something similar to this:

currency-converter-wsdl.png

A few things you might notice is that the web service uses currency codes for different currencies and these are defined in the WSDL. For example, AUD for Australia Dollars, NZD for New Zealand Dollars, USD for American Dollars and EUR for Euros.

Let's load the web service in soapUI and have a look at what it can do.

Start soapUI and create a new project. Fill in the following:

Leave the rests of the options at their defaults.

currency-converter-soapui-project.png

Once the project loads, expand out the project until you get to the Request:

currency-converter-soapui-request.png

Double click on the request to load the SOAP editor. This allows you to edit the XML (SOAP envelope and data) that will be sent to the web service. In particular take note of the question marks (?) which is where you need to supply data.

currency-converter-soapui-request-xml.png

Change the From Currency to AUD and the To Currency to USD. This gives you the exchange rate from AUD$1 to USD$1. As you can see at time of writing AUD$1 is worth USD$1.0031.

currency-converter-soapui-response.png

Now that we know how to work with the web service, the next step is to consume the web service from PeopleSoft.

Consuming the Web Service

PeopleSoft provides a wizard for consuming web services as part of Integration Broker.

This wizard is available from:
PeopleTools > Integration Broker > Web Services > Consume Web Service

The first step in the wizard is to specify the WSDL:

consume-web-service-step-1.png

Next, review the web service in step 2. You can click on the View WSDL hyperlink to view the WSDL in your browser as we did in the first part of this tutorial.

consume-web-service-step-2.png

This web service has 4 service ports or variations of the web service. Select the first, CURRENCYCONVETORSOAP service port.

consume-web-service-step-3.png

Next, you get to choose the service operation. There is only one in this case - ConversionRate.

consume-web-service-step-4.png

Being a synchronous service, there are two messages - request and response. The next step creates these messages and optionally allows you to
rename them if necessary (note that you have skipped over step 5).

consume-web-service-step-6.png

The final step is to select the receiver node, which by default will be WSDL_NODE.

consume-web-service-step-8.png

Make sure you press Finish on this step to consume the web service.

This will give you a final screen that confirms the results and allows you to view your consumed web service:

consume-web-service-confirm-results.png

Click on the View Consumed Service to open the service and see the IB definitions that have been created.

consume-web-service-view-consumed-service.png

Creating a Pagelet to view your consumed web service

Now that we have consumed a web service, let's do something with it. In this case, I'm going to use the pagelet wizard to create a really
simple pagelet that displays the results of the web service based on user specified parameters.

Navigate to:
PeopleTools > Portal > Pagelet Wizard > Pagelet Wizard

To start the Pagelet Wizard. Add a new value with a Pagelet ID of CURRENCY_CONVERTER.

In step 1, specify some basic information about the pagelet:

currency-converter-pagelet-wizard-step-1.png

In step 2, specify the data type as Integration Broker. Then fill in the service as CONVERSIONRATE and the receiver node name as WSDL_NODE.

currency-converter-pagelet-wizard-step-2.png

In step 3, change the FromCurrency and ToCurrency field usage types from Fixed to User Specified. This means that when the pagelet is
enabled by the user, they can also set the From and To currency codes used by the pagelet to display the conversion rate.

currency-converter-pagelet-wizard-step-3.png

Click on the Values links to set the From/To currency to the defaults you want to use (this will be a prompt):

currency-converter-pagelet-wizard-step-3-values.png

In step 4, you specify the pagelet format. There is only one option in this case - custom format.

currency-converter-pagelet-wizard-step-4.png

In step 5, you specify the pagelet display options which control how the pagelet is presented to the user. Select an XSL template of Table and press the generate button. Also set the opening text to Freeform/HTML and enter the HTML <strong>Conversion Result:</strong>.

currency-converter-pagelet-wizard-step-5.png

In step 6, specify the pagelet as a homepage pagelet in the folder PeopleSoft Applications. Expand the Advanced Options and select the
Requires Personalization check box. Click finish or save to complete the wizard.

currency-converter-pagelet-wizard-step-6.png

Enabling the Pagelet

To enable the pagelet, return to the PeopleSoft home page (home link on the navigation bar). Click on the Content link after the Personalize text above the main menu:

enable-pagelet-perosnalize-content.png

Select the check box for the currency converter pagelet under PeopleSoft Applications.

enable-pagelet-select-pagelet.png

Press save, and this will take you back to the home page. Scroll down, and you should see the pagelet below your main menu.

enable-pagelet-requires-customization.png

As you can see, it will tell you that the pagelet requires customization - the from/to currency codes need to be specified. Click on the
Customize this pagelet hyperlink. Select your from/to currency codes, and save.

enable-pagelet-from-to-currency.png

Once you return to the home page, you should now see the currency coverter in action.

currency-converter-pagelet.png
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License