Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Publishing JSR 168 Portlets as Remote Portlets With WSRP

 
By Manish K. Gupta and Marina Sum, July 27, 2006  

Java Specification Request (JSR) 168: Portlet Specification enables interoperability among portlets and portals by defining the APIs that standardize preferences, security, and other configurations. By taking advantage of the Web Services for Remote Portlets (WSRP) capability in Sun Java System Portal Server 7 (henceforth, Portal Server), you can publish a locally deployed JSR 168 portlet as a remote one and consume or display other remotely published portlets in Portal Server.

This article describes the publication procedure with an example portlet and offers troubleshooting tips.

Contents
 
Prerequisites
Deploying a JSR 168 Portlet
Creating a Channel for the Local Portlet
Creating a WSRP Producer
Creating a WSRP Consumer
Creating a Channel for a Remotely Published Portlet
Viewing a Remote Portlet
Conclusion
References
 
Prerequisites

This article assumes the following:

  • You have installed Portal Server and can view the welcome portal at http://hostname:portnumber/portal/dt. For details, see the Portal Server main page.

    If you installed Portal Server in a Sun Java System Web Server (henceforth, Web Server) container, the default port number is 80. If you deployed Portal Server on Sun Java System Application Server, the default port number is 8080.

  • You can access the Portal Server administration console (admin console for short) at http://hostname:portnumber/psconsole.

    To log in to the admin console, use the same user name and password that you set up when installing Sun Java System Access Manager. The default for both is amadmin.

  • You have downloaded the example portlet's WAR file, helloportlet.war. This article shows you how to publish that portlet as a remote one.
Deploying a JSR 168 Portlet

Similar to Java servlets, JSR 168 portlets require a runtime environment, called the portlet container, and you must deploy them by means of portlet container-specific utilities. You can deploy portlets in Portal Server from either the command-line interface (CLI) or the Portal Server admin console.

Follow these steps to deploy a portlet from the admin console:

  1. Log in to the admin console.

  2. Click the Portals tab to display a list of the existing portals.

  3. Click portal1 to view its admin screen, which contains tabs for managing the desktop, WSRP, logging, and so forth. See Figure 1.

    Figure 1: Admin Screen for portal1
    Figure 1: Admin Screen for portal1
     
  4. Choose DeveloperSample [Org] from the Select DN drop-down list and click Deploy Portlet under the Tasks list.

    The Deploy Portlet wizard is displayed.

  5. Keep the default selections, portal1 under Select Portal and DeveloperSample [Org] under Select DN. Click Next.

    The pane for Step 2: Enter the Portlet Information is displayed.

  6. Type the path for the helloportlet.war file in the Portlet WAR File text field and leave the other text fields blank.

  7. Click Finish.

Troubleshooting tips: In case of deployment failure, browse the portal admin log at /var/opt/SUNWportal/logs/admin/portal.admin.console.0.0.log for clues. Also, if your portal is deployed on Web Server, ensure that Web Server's administration server is running before deploying your portlet.

Creating a Channel for the Local Portlet

Next, make the locally deployed portlet available for publishing with WSRP by creating a channel for the portlet. A channel is a portal window that shows a portlet's content, which might originate from a locally deployed portlet or from a remote portlet.

Follow these steps to create a portlet channel:

  1. From the portal1 admin screen (see Figure 1), click Manage Containers and Channels under the Tasks list.

    Note: Ensure that you have chosen DeveloperSample [Org] from the Select DN drop-down list to add the channel to the DeveloperSample organization.

    The Manage Containers and Channels wizard is displayed.

  2. Choose DP XML Tree from the View Type drop-down list in the left navigation area and then click DP_Root.

    The DP_Root pane is displayed on the right.

  3. Click New Channel or Container under the Tasks list.

    The New Channel or Container wizard is displayed.

  4. Keep the default selections, portal1 under Select Portal, DeveloperSample [Org] under Select DN, and the Channel radio button selected under Type. Click Next.

    The pane for Step 1.1: Specify Channel Type is displayed.

  5. Select JSR 168 Portal Channel under Channel Type and then click Next.

    The pane for Step 2: Specify Provider/Portlet/Producer Name is displayed, which shows a drop-down list of the deployed portlets.

  6. Choose helloportlet.HelloWorldPortlet from the list and then click Next.

    The pane for Step 3: Specify Channel Name is displayed.

  7. Type a name for the HelloPortlet example portlet, for example, Hello World, in the Channel or Container Name text field. Click Next.

    The review pane with all the settings is displayed. If there are errors, click Previous and edit the settings as appropriate.

  8. Click Finish.

Troubleshooting tips: If HelloWorldPortlet is not on the deployed portlet list, either you have not deployed the portlet at the DeveloperSample DN or you are not creating a channel at that DN.

Creating a WSRP Producer

To publish a local portlet as a remote portlet with WSRP, first create a WSRP producer—a Web service that offers one or more locally deployed portlets as remote portlets—by implementing WSRP interfaces and operations. You can create multiple producers to offer unique portlets to different consumers. For example, one producer could produce portlets for an intranet and another producer could produce portlets for an extranet.

Follow these steps to create a WSRP producer in Portal Server:

  1. From the portal1 admin screen (see Figure 1), click the WSRP tab for the WSRP Consumer admin screen.

    Again, ensure that you have chosen DeveloperSample [Org] from the Select DN drop-down list.

  2. Click the Producers tab to access the WSRP Producers admin screen and then click New to access the New Producer wizard.

  3. Type a name for the new producer in the Name text field, for example, DemoProducer.

  4. Keep the default, Required, selected for Registration. Click Next.

    The pane for Step 1.1: Specify Registration Parameters is displayed.

  5. Keep the default selection, Supported, under Inband Registration. Click Next.

    The pane for Step 2: Review with all the settings is displayed.

  6. Click Finish and then click Close on the pane for Step 3: Results.

    The WSRP Producers admin screen displays the newly created producer, DemoProducer, as a new item under WSRP Producers with a disabled status. Enable it by publishing at least one portlet through this producer.

To enable DemoProducer:

  1. Click DemoProducer on the producer list.

    The Edit Properties for Producer - DemoProducer screen is displayed with the message, "To enable this producer, publish one or more portlets and save." Listed under Portlets are the published and unpublished portlets. HelloPortlet is on the list of unpublished portlets.

  2. Select HelloPortlet from the unpublished portlet list and click Add.

    Portal Server moves HelloPortlet from the unpublished portlet list to the published portlet list.

  3. Select Enabled under Status to enable DemoProducer and then click Save to have DemoProducer publish HelloPortlet.

Now click the WSDL URL to see the WSDL file associated with the DemoProducer Web service. Copy and save that URL. You will need it later for creating the WSRP consumer.

Creating a WSRP Consumer

Next, create a consumer for the portlet offered by the producer you just generated. A WSRP consumer is a Web-service client, typically a portal, that invokes producer-offered WSRP Web services and that provides an environment for users to interact with portlets offered by one or more producers.

In reality, the portlet published by one portal (called a producer portal) is consumed by another portal (called a consumer portal). For testing purposes, you can have a single portal act as both the producer portal and consumer portal.

Follow these steps to create a consumer in Portal Server:

  1. On the WSRP admin screen, verify that you have chosen the DeveloperSample [Org] from the Select DN drop-down list. Click the Consumer tab.

    The Consumer admin screen is displayed.

  2. Click New.

    The New Consumer wizard is displayed.

  3. Type a name, for example, DemoConsumer, in the Producer Name text field and choose None from the User Identity Propagation Mechanism drop-down list. Click Next.

    Note: The name of the Producer Name text field is a typographical error. It should read Consumer Name instead.

    The pane for Step 2: Specify WSDL URL is displayed.

  4. Paste the URL from the preceding section in the WSDL URL text field. Click Next.

    The pane for Step 1.1: Specify Registration Parameters is displayed.

  5. Keep the default selection, Supported under Inband Registration. Click Next.

    The Registration pane is displayed.

  6. Leave the fields blank because DemoProducer does not require any configurations for registration. Click Next.

    The review pane with all the settings is displayed.

  7. Click Finish.
Creating a Channel for a Remotely Published Portlet

You are now ready to create a channel for HelloPortlet, which you just published remotely.

  1. From the portal1 admin screen (see Figure 1), click Manage Containers and Channels.

    Note: Ensure that you have chosen the DeveloperSample DN [Org] from the Select DN drop-down list.

    The Manage Containers and Channels screen is displayed.

  2. Choose JSPTabContainer [Default] from the View Type drop-down list in the left navigation area.

  3. Under the JSPTabContainer list on the left, click WSRPSamplesTabPanelContainer.

    The JSPTabContainer/WSRPSamplesTabPanelContainer properties pane is displayed on the right.

  4. Click New Channel or Container under the Tasks list.

    The New Channel or Container wizard is displayed.

  5. Keep the default selections, portal1 under Select Portal, DeveloperSample [Org] under Select DN, and the Channel radio button selected under Type. Click Next.

    The Step 1.1: Specify Channel Type pane is displayed.

  6. Select WSRP Remote Portlet Channel under the Channel Type list and then click Next.

    The Step 2: Specify Provider/Portlet/Producer Name pane is displayed.

  7. Choose DemoConsumer from the Configured Producer drop-down list because a configured producer is another term for a consumer. Click Next.

    The Step 2.1: Specify Remote Portlet pane is displayed, which shows a Remote Portlet drop-down list with the portlets that are available for DemoConsumer.

  8. Choose HelloPortlet from the list and click Next.

    The Step 3: Specify Channel Name pane is displayed.

  9. Type a name, for example, HelloWorldRemote, for HelloPortlet in the Channel or Container Name text field. Click Next.

    The review pane with all the settings is displayed.

  10. Click Finish.
Viewing a Remote Portlet

You can now see the remote portlet in action. Log in to the DeveloperSample portal with developer as both the user ID and the password. After authentication, click the WSRP Samples tab. Voilà! HelloWorldPortlet is displayed. See Figure 2.

Figure 2: HelloWorldPortlet
Figure 2: HelloWorldPortlet
 
Conclusion

Publishing a local JSR 168 portlet as a remote portlet with WSRP in Portal Server is a simple process that requires no programming efforts. Your portal can then consume or display other remote portlets and become much more versatile. Try it out!

References
Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.
The Portal Post
 
Manish K. GuptaManish K. Gupta, a member of technical staff at Sun's India Engineering Center in Bangalore, joined the Sun Java System Portal Server development team in October 2004. He is currently engaged in the open-source efforts for Portal Server. Manish blogs regularly on a variety of topics.
 
Marina SumMarina Sum is a staff writer for Sun Developer Network. She has been writing for Sun since 1989, mostly in the technical arena. Marina blogs on Sun products, technologies, events, and publications.