Gerald Nunn's Blog

« Multilingual Documentum Content in WebLogic Portal | Main | Handling events for a WSRP portlet locally »

WSRP and Remote Resources

Wednesday, March 01, 2006

If your new to Web Services for Remote Portlets (WSRP), you may not be aware of a feature in WebLogic Portal that enables users to access images and resources from a remote portlet.

Web Services for Remote Portlets (WSRP) is something I've recently been doing a lot of work with at various clients as this specification seems to be gaining some traction in the market. It is of particular interest to larger enterprise's that want to leave control of the development and deployment of functionality, including the user interface, to their various line's of business while still aggregating the functionality into a single application.

If your not familiar with WSRP, it's paradigm is that a consumer proxies access to content from various producers to the user's browser. For example, if a consumer accesses the portal, the portal (called the consumer) in turn accesses the various remote producers providing content on behalf of the user making the request. The HTML markup returned by the producers is then rendered inline with the rest of the content to the user's browser.

This means that the user never directly accesses any of the producers and often does not have physical access to the producers which can be behind a corporate firewall. As a result, a common question is how to make resources such as images available to the user. Keep in mind that resources are typically rendered as links or URLs in the content and the browser resolves these independently after it receives the HTML. If the resource is on a producer that is not accessible by the browser, the browser will fail to retrieve it.

Fortunately a relatively little known feature with respect to WSRP in WebLogic Portal is the ability to proxy images and other resources from the producer through the consumer to the user's browser. If you have a portal application and look at the web.xml for the application, you will notice that a ResourceProxyServlet is specified. This servlet is responsible for proxying resource requests from the consumer portal to the producer.

The way it works is that URLs for resources on the producers are mapped to the ResourceProxyServlet on the consumer. This mapped URL includes various parameters that enable the ResourceProxyServlet to determine where to go to retrieve the content. Thus when the user’s browser attempts to resolve this resource, it makes the request against the consumer, not the producer, and the consumer proxies the request to the underlying producer. In this way the user's browser never directly accesses the producer.

To use the proxying capability, we simply need to use the render:resourceUrl custom tag provided by WebLogic Portal. When this tag is used, WebLogic Portal automatically rewrites the URL to use the consumer resource proxy when the portlet is being accessed through WSRP. For example:

<img src='<render:resourceUrl path="/demo/resources/images/weblogic-img-lt.jpg"/>'>

Now keep in mind that this proxying obviously adds another hop to the process and can have some impact on performance. It likely is not as significant as one would first think since the browser caches most of these resources, however it is worthwhile to consider centrally locating common images and resources that are shared among multiple producers.

Posted by Gerald Nunn at 4:02 PM | Categories: WebLogic | Permalink