Show TOC

Component documentationCalling Portal Services Locate this document in the navigation structure

 

Web Dynpro applications can access portal services in one of the following ways:

  • Directly: The application can get an instance of the service on the machine on which the Web Dynpro application is running.

  • Via the Service Factory: The application can request an instance of the service from the service factory. The service factory provides a conduit to portal services to ensure that the proper service is called, even in cases when the Web Dynpro application and the portal are running on different machines.

    Only services written in a remote-safe manner are available via the service factory. These services include the following portal services:

Note Note

A portal service can be called only when the portal platform and the Web Dynpro application are running on the same machine. Therefore it is recommended not to use your Web Dynpro-based portal content in a global or federated portal scenario.

End of the note.
Procedure

This section describes how to call a portal service.

For services whose interfaces are provided by Web Dynpro (such as IWDPageService and IWDTrayService), you do not need to perform Steps 1 and 2.

  1. Make a sharing reference to the service, by doing the following:

    1. Right-click the Web Dynpro development component or Web Dynpro project, and select Properties.

      The Properties dialog box opens.

    2. From the left pane, select Web Dynpro References.

    3. In the Sharing references tab, add a reference to the portal service with the following format:

      PORTAL:<Vendor name>/<Fully qualified name of the portal service application>

      For example, the following shows a reference to the navigation service:

      This graphic is explained in the accompanying text.

  2. To build the project, add the JAR file containing the service to the classpath of the project in the IDE.

    Caution Caution

    Do not store the JAR file of the service in the lib folder of your development component or Eclipse project. This causes classloader problems at runtime.

    End of the caution.
  3. Get an instance of the service.

    To call a portal service directly, without the service factory, call WDPortalUtils.getServiceReference() with the key for the service, as in the following example:

    Syntax Syntax

    1. IUserObjectBasedNavigation obnService = (IUserObjectBasedNavigation)
          WDPortalUtils.getServiceReference(IUserObjectBasedNavigation.KEY);
      
    End of the code.

    To call a portal service via the service factory, call WDPortalUtils.getService() with the WDPortalServiceType constant for the service, as in the following example:

    Syntax Syntax

    1. INavigationService navService = (INavigationService)
          WDPortalUtils.getService(WDPortalServiceType.NAVIGATION)
    End of the code.

If more than one Web Dynpro controller needs to use the same portal service, you can store the portal service reference in a controller context node. All other controllers that need to use the service must define a context node and map it to the context node with the service reference.