Inside WSRP
Pages: 1, 2, 3, 4, 5

Displaying a Remote Portlet

The portal uses WSRP to get the markup (in this case, the HTML generated for this portlet) from the Producer. When the WebLogic Portal framework finds a remote portlet in a page, it does the following:

  • Sends a getMarkup message to the Producer and receives the response from the Producer.
  • Collects the markup from the Producer's response
  • Aggregates the markup into the portal page

If the remote portlet has a backing file, WebLogic Portal will call its methods in the appropriate order. Here is a typical getMarkup request that a Consumer sends to a Producer.

<soapenv:Envelope xmlns:soapenv="">
      <urn:getMarkup xmlns:urn="urn:oasis:names:tc:wsrp:v1:types">
         <urn:registrationContext xsi:nil="true" 
               <!-- Snip -->
         <urn:userContext xsi:nil="true" 
               Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; 
                  .NET CLR 1.1.4322; FDM)

In the above request, let's look at the lines highlighted in bold:

  • As mentioned above, the Consumer supplies the portletHandle assigned by the Producer.

  • The portletInstanceKey and namespacePrefix are based on the value of the instanceLabel of the remote portlet. This is assigned by the user creating the remote portlet.

  • The value of the locales element is based on the language requested by the browser and corresponds to the Accept-Language HTTP request header received from the user's browser. If the browser sends multiple values for this header, WebLogic Portal Consumer sends all those values in the same order to the Producer.

  • The values of the mimeTypes element is based on the content type set on the portal response, followed by the values of the Accept HTTP request header received from the user's browser.

  • The mode and windowState elements correspond to the window mode and window state of the remote portlet.

Note: In the WSRP protocol, the Consumer keeps track of the mode and window state of the portlet.

Let's now look at what the WebLogic Portal Producer does when it receives a getMarkup request from a Consumer:

  • Based on the portletHandle, the Producer identifies the corresponding portlet.

  • Based on the value of the mode element, the Producer identifies that this request should invoke the begin action of the Page Flow specified by the pageFlowContent element in the portlet file.

  • The Producer invokes the begin action of the Page Flow and includes the beginning page (which is index.jsp in this example).

  • The Producer then collects the response and creates the SOAP response message.

Here is a sample response from the Producer.

<soapenv:Envelope xmlns:soapenv="">
      <urn:getMarkupResponse xmlns:urn="urn:oasis:names:tc:wsrp:v1:types">
<urn:mimeType>text/html; charset=UTF-8</urn:mimeType>
 <form name="searchForm" action="http://localhost:7001/consumer/test.portal?_nfpb=true
 _action%3D%252FSearch%252Fsearch&wsrp-mode=&wsrp-windowState=" method="post">
        <tr valign="top">
            <td>First Name:</td>
            <td><input type="text" name="search_1{actionForm.firstName}" value=""></td>
        <tr valign="top">
            <td>Last Name:</td>
            <td><input type="text" name="search_1{actionForm.lastName}" value=""></td>
    <input type="submit" value="search">


Let's again look at the lines highlighted in bold in this response.

Tip: By default, the Producer returns the portlet's markup via the markupString element as shown above. WebLogic Portal Producer is also capable of returning the markup as BASE64-encoded bytes in a markupBinary element or outside the SOAP Envelope as a MIME attachment.

If the portlet's markup is larger than 8k, you may improve performance by configuring the Producer to return the markup as a MIME attachment. Refer to WebLogic Portal WSRP documentation for configuration details.

  • The mimeType element indicates that the Producer rendered the portlet to generate text/html markup with UTF-8 character encoding. The portlet could influence this value using the JSP page directive for Content-Type, or the setContentType() method on the HttpServletResponse.

  • The markupString element includes the response generated by the portlet. In our example, this is the HTML generated from the index.jsp page of the search Page Flow. To invoke portlets, the Producer uses custom request/response wrappers. These wrappers mimic a web container environment although the incoming request is a SOAP request and not an HTTP request.

  • The form's action element refers to the Consumer's portal. This is accomplished by using the URL templates sent by the Consumer. For more information on URL templates, refer to the article on URLs in WebLogic Portal.

  • The Producer rewrote the names of the form's input controls using the Consumer-supplied namespacePrefix element. This was done to ensure that the names don't collide with the name attributes of other HTML elements present in the portal's page and those present in the action target of the HTML form.

  • The sessionContext element includes the ID of the HTTP session created by the Producer or the portlet. In our current example, the Page Flow runtime created an HTTP session while executing the Page Flow's begin action. I will discuss session management in more detail later in this article.

Upon receiving the response for the getMarkup request, WebLogic Portal Consumer extracts the markupString and writes it to the portal's HTTP response, making the portlet visible to the end user.

It is important to realize how accessing request parameters affects portability. When you deploy this portlet as a local portlet, the portlet can access the request parameters from the portal's request and request attributes set by other portlets on the same page. If you implement a portlet to depend on such request parameters and attributes, the portlet may not function correctly in a WSRP environment. Note that in a WSRP environment, the portlet is remote, and the HTTP request received by the portlet (on the Producer) is not the same as the one received by the portal (on the Consumer).

If your use cases depend on such parameters/attributes, you can use the Custom Data Transport APIs to send that data explicitly from the Consumer to the Producer.

Pages: 1, 2, 3, 4, 5

Next Page ยป