cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a portal service from a servlet

Former Member
0 Kudos

Hello all.

I have a functioning portal service that I would like to call from a servlet.

When I try to do so, I get a ClassCastException when I do this (on line two):

IPortalRuntimeResources runtimeResources = PortalRuntime.getRuntimeResources();
IDocumentPersistence docPer = (IDocumentPersistence) runtimeResources.getService(IDocumentPersistence.KEY);

However if I do the following I can get a generic IService and use reflection to invoke the method (in the IDocumentPersistence interface) that I want to invoke:

IPortalRuntimeResources runtimeResources = PortalRuntime.getRuntimeResources();
com.sapportals.portal.prt.service.IService aService = (com.sapportals.portal.prt.service.IService) runtimeResources.getService(IDocumentPersistence.KEY);

There must be a better way to use portal services (hopefully like scenario one above) in servlets. In web dynpro you can use portal services and cast them to the correct type. What am I missing?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kim,

how did you integrate the references to your Portal Service Interface into your web application?

You should do this using the references in your application-j2ee-engine.xml, did you do this? It might be a problem with the classloader otherwise.

The way you are calling portal services does work normally, however it is not the recommended way as it is documented in the SAP documentation.

Please check the SAP documentation on how to access a portal service from a j2ee app:

http://help.sap.com/saphelp_nw70/helpdata/EN/42/9ddd0cbb211d72e10000000a1553f6/frameset.htm

Best regards,

Stefan Brauneis

Answers (0)