Tuesday, September 11, 2012

Consume Portlets from WAS using WSRP

Now as we know we can deploy the portlets on WAS as it comes with portlet container here I will explain how the portlets deployed on WAS can be exposed from WAS as a web service and can be consumed by portal using WSRP.

Noe : WAS server used here is a standalone WAS 7 (server1) instance and not the one on which portal server runs over.

Now  if you look on of my older post it describes how you install the war file containing portlets on WAS so in this post I will assume that you are ready with that stuff.


So after installing the war files in the WAS we need to expose the portlets from was as a webservice for this we need to deploy a special EAR from IBM (Consider it as an out of box),this ear helps to expose the portlets from WAS as a webservice. (EAR file along with detailed PDF with instruction is available in backup email.)

Name of EAR (was.wsrp.producer.ear)

To access server1 admin console I used following url (https://localhost:9043/ibm/console/login.do?action=secure)

While deploying the EAR (In select deployment option page(i.e step1) you need to  check deploy as a webservice option in the checkbox)

After EAR is installed and started in WAS try to hit following url in browser you should be able see a wsdl

http://localhost:9080/producer/wsdl/wsrp_service.wsdl

Copy the above url and and log into the admin console of WebSphere portal where you want to consume the portlets from WAS

Go to webservice section in left panel of admin console
click new producer button

Fill the necessary details and  enter the wsdl url in the form and save it (if WAS server is remove localhost in the above url can be replaced with IP ).

Next step is you go to web modules section and click the consume button you should be able to see the newly created service

Lastly you can go to the portlets section search for the portlets with name installed in the WAS,you should be able to search the portlets and add them on the portal page.


Thus using above method we can consume the portlets deployed on WAS into the portal using WSRP

All the related material along with the PDF of instructions is available in backup email.


Accessing Portlets from WAS

Now here is a new thing I came to know,IBM has put in a portlet container into WAS 7 and maybe 6.1 as well. So I tried to run a portlet into WAS 7 and was successful. So without wasting time here are the steps to do it .

Note : - Portlets cannot run on WAS supplied with portal or on the WAS on which Portal server is running,so we need to deploy and run the portlets on server1 instance i.e separate standalone WAS.

If you try to run the portlet on the WAS on which portal server is running you might get an error such as "Direct portlet access prevented by WebSphere Portal ".

To access server1 admin console I used following url (https://localhost:9043/ibm/console/login.do?action=secure)

Step1 : Take a war containing portlets.

Setp 2 : Install the war in into the WAS

Step 3 : Provide the context root (eg /test)

Step 4 : Select server as server1

Step 5 : With all default settings complete the setup

Step 6 : Make sure war file is started

Now hit the following url in the browser to see the portlet

http://localhost:9080/mohit/SamplePortlet

format (http://localhost:9080/contextroot/portlet name as per portlet.xml)

By hitting the above url one should be able to see the portlet from WAS though basic features of portal will be missing from portlets as its running from WAS.