# Oracle9iAS Portal Developer Kit (PDK)
Installing the Web Services Sample Portlets

Creation Date: | Sep 26, 2002
Status: | Final (1)
Version: | PDK Release 2, (9.0.2.5 and later)

# Introduction

PDK provides a sample provider containing web services portlets that can be configured to run out-of-the-box. These portlets help you understand the usage of web services renderers that PDK provides. These samples consume publicly available web services not under the control of Oracle Corporation.

This document explains how to configure the sample web provider that illustrates the basic web service support provided by PDK. You can also get a basic understanding about using web services in portlets from the article Understanding Web Services for Portlets.

### Assumptions

You have installed PDK as described in the article Installing the PDK Framework and samples

## Configuring the Sample Provider

The web service renderer sample portlets are contained in a pre-configured web provider with a service ID of "urn:ws". Registering the provider is therefore just as simple as registering any of the other PDK sample providers. However, if your web provider is running inside a firewall (as utilized in many corporate networks), there is an extra configuration step you must take to ensure that external Web Services, such as the ones used by the samples can be contacted by the web provider through HTTP. This is explained in the following subsection.

#### Configuring OC4J for Proxy Server

If you have to use a proxy server to access the internet from the machine that your web provider will be running on it is important that you set the http.proxyHost and http.proxyPort system properties appropriately when you start up OC4J.

http.proxyHost should be set to the host name of your proxy server
http.proxyPort should be set to the port number your proxy server uses for HTTP communications (usually 80)

If you are unsure of these settings, you may be able to determine them from your browser configuration.
Use the -D JVM command line option to define these system properties when you start up OC4J. For example:

java -jar -Dhttp.proxyHost=my.proxyserver.com -Dhttp.proxyPort=80 oc4j.jar

Once you have determined the correct settings to use, you might want to configure a shortcut (on Windows) or command alias (on UNIX) that runs this command automatically.

## Accessing the Provider Test Page

Once OC4J is up and running with the required proxy settings (if any) you should access the web service provider test page to ensure that PDK-Java has been configured correctly. This can be done by accessing the following URL.

http://<host name>:<port number>/jpdk/providers/ws

> There are several sample portlets included with the this sample. They are:

> ### Samples

- Simple Samples for Web Services

- WhoIs
- StockQuote
- Dictionary

- Parameter Passing Samples : You could use these samples by passing zipcode either as a URL parameter or as a page parameter to these portlets.

- ZipcodePortlet : Master portlet for providing URL parameter, if you're not using page parameters configurable in Oracl9iAS Portal Release 2.
- LocationInformation :
- LocalWeatherInformation :
- WeatherwithDefault StyleSheet :
- LocalTimeInformation :
- LocalTemperature :

- Newsfeed Sample

- OTN News

- Personalization Sample (User Preferences)

- ZipcodeInYourArea

- Personalization Sample (Admin Preference with Edit Defaults Mode)

- MessagingWebServices

You should see a congratulatory message and a listing of the portlets included in the provider. If not, then carefully review the instructions in the installation guide. Note that reaching this page does not necessarily mean that your proxy settings are correct, as these will only be tested on the first request from Portal to render the portlets.

## Registering the Samples Provider with Portal

### On Oracle9iAS 9.0.2 Portal

Under the Build tab (on the Builder Page), click on Register a Portlet Provider within the portlet called Providers.

1.On the first page of the wizard, fill in the following information

Name: WebServicesProvider

Display Name: Web Services Sample Provider

Timeout: 100

Implementation Style: Web

2.On the second page, fill in the following information

URL: http://<host name>:<port number>/jpdk/providers/ws

Service Id: urn:ws

Login Frequency: Never

3.Click Finish

Once registered, all the sample portlets are displayed in the Portlet Repository.

## Adding Sample Portlets to a Page

Display the contents of the Portlet Repository and review the sample portlets. Add any of the sample portlets listed under the Provider called "Web Service Sample Provider" to a Portal page

### Create Simple Web Services page

Once you have registered the web service sample provider, you will probably want to add its portlets to a page in the usual manner. The portlets that you can view are the Stock Quote Service portlet, Dictionary Service portlet and the Who Is Web Service portlets. Try submitting values to each of the portlets in turn and note the results you get back.

### Create City Search Samples page

Similarly, create a new page for parameter communicating web service portlets based on zipcode. Add the following portlets - J2EE zip code entry portlet, Location Web Service Portlet, Weather Web Service Portlet, Weather Web Service Portlet with Default StyleSheet and Temperature Web Service potlet - to a page.

On the top left portlet, put the master J2EE-based portlet that takes a Zip Code as input and drives the other portlets. You can enter any valid zip code and it displays corresponding information in the other four web services portlets.

You have now successfully installed and setup the Web Services Samples.

### Understanding the provider.xml

You can view the source provider.xml, (found under the <OC4J HOme>/j2ee/home/applications/jpdk/jpdk/WEB-INF/providers/webservices directory) to understand how these Web Services portlets have been invoked.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?providerDefinition version="3.1"?> <provider class="oracle.portal.provider.v2.DefaultProviderDefinition"> <session>true</session> <preferenceStore class="oracle.portal.provider.v2.preference.FilePreferenceStore"> <name>prefStore1</name> <useHashing>true</useHashing> </preferenceStore> ...... <portlet class="oracle.portal.provider.v2.DefaultPortletDefinition"> <id>4</id> <name>ZIPCodePortlet</name> <title>ZIP code portlet</title> <description>This portlet queries the ZIP code and sends a public parameter to the page.</description> <timeout>30</timeout> <timeoutMessage>ZIP code portlet timed out.</timeoutMessage> <showLink>false</showLink> <showEdit>false</showEdit> <showEditToPublic>false</showEditToPublic> <showEditDefault>false</showEditDefault> <showPreview>true</showPreview> <showDetails>false</showDetails> <hasHelp>false</hasHelp> <hasAbout>false</hasAbout> <acceptContentType>text/html</acceptContentType> <defaultLocale>en.US</defaultLocale> <renderer class="oracle.portal.provider.v2.render.RenderManager"> <autoRedirect>true</autoRedirect> <contentType>text/html</contentType> <showPage>/htdocs/webservices/zipcode_form.jsp</showPage> </renderer> </portlet> <portlet class="oracle.portal.provider.v2.DefaultPortletDefinition"> <id>5</id> <name>LocationInformation</name> <title>Location Web Service Portlet</title> <shortTitle>Location Information</shortTitle> <description>Web Service demonstration portlet.</description> <timeout>100</timeout> <timeoutMessage>Location Information portlet timed out</timeoutMessage> <acceptContentType>text/html</acceptContentType> <inputParameter class="oracle.portal.provider.v2.DefaultParameterDefinition"> <name>p_zip</name> <displayName>Please enter zipcode</displayName> <description>Please enter zipcode</description> </inputParameter> <renderer class="oracle.portal.provider.v2.render.RenderManager"> <contentType>text/html</contentType> <charSet>UTF-8</charSet> <showPage class="oracle.portal.provider.v2.webservice.DocWebServiceRenderer"> <contentType>text/html</contentType> <logging>false</logging> <endpointURL>http://www.alethea.net/webservices/ZipCode.asmx</endpointURL> <soapAction>http://www.alethea.net/webservices/ZipCodeToCityState</soapAction> <literal class="oracle.portal.provider.v2.webservice.LiteralXML" handler="oracle.portal.provider.v2.webservice.LiteralXML$Handler"> <element name="ZipCodeToCityState"> <attribute name="xmlns">http://www.alethea.net/webservices</attribute> <element name="ZipCode" bind="urlParams/p_zip" default="94065" prompt="Please enter a zipcode"/> </element> </literal> <!-- This service produces HTML as output, so don't escape tag information --> <escapeOutput>false</escapeOutput> <responseXSL>CityState.xsl</responseXSL> </showPage> </renderer> </portlet> ... </provider>

### Create Messaging Sample page

Create another page or to the same page, add the SMS Messaging Web Service portlet and you can send messages to anyone. You first need to enter the Edit Defaults mode and provide an OTN username and password to configure this sample. You can even send a Voice message by entering the To address as: "Voice:1-650-555-1234" (use your own phone number to test).

Please refer to Oracle9iAS Portal online documentation for more information about using Web Services Renderers, read the articles Understanding Web Services for Portlets and How to Build Portlets using Web Services.

Oracle Corporation World Headquarters 500 Oracle Parkway Redwood Shores, CA 94065, USA http://www.oracle.com/ | Worldwide Inquiries: 1-800-ORACLE1 Fax 650.506.7200 | Copyright and Corporate Info