Showing results for 
Search instead for 
Did you mean: 

calling portal service ?

Former Member
0 Kudos


am trying to call a portal service from portal application.

2 scenarios:


componnent and the service in the same project.

in the KEY filed of ImyService. when I provide the value as Parfilename|servicename, it works

when i change the KEY field to name of the classfile, i.e. com.mycomp.myService [ implemention class of that interface], it doesnt work. throwing exception "could not instatiate the implementation class".


SERVICE and the usage component is in different projects and I provided the value of service to sharingreference in the portalapp.xml file

it doesnt work when the KEY is "Parfilename|servicename" or when it is set to the class file name, i.e. "com.mycomp.myService".

BTW, the portal service is started.

any ideas are highly appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Yogi,

The Steps below Describes how to call a Portal Service from a Portal Application.

<b>Add Sharing Reference Value in the Deployment Descriptor.</b>


<property name=”SharingReference” value=”<ApplicationName or ApplicationAlias>”/>

<property name=”SharingReference” value=””/>


<b>Add Libraries of the Portal Service (xxxapi.jar)</b>

<b>Write code to access the Portal Service</b>

Import Package of the Portal Service

Get Instance of the Portal Service

Call Methos of the Portal Service.

<b>Here is an Example:</b>


/********************** Service Interface : ************************/


import com.sapportals.portal.prt.service.IService;

public interface IServiceOne extends IService


public static final String KEY = "ServiceProject.ServiceOne";


public String display();


/**************** Service Source File : ***************************/

// Implement the display() Method

public String display() {

// TODO Auto-generated method stub

return "Welocme To My Service Project. Thank you for accessing my service.";







<service name="ServiceOne">


<property name="className" value=""/>





<b>After Creating Your Service , Deploy it on the Server.</b>


package com.sample;


import com.sapportals.portal.prt.component.*;

import com.sapportals.portal.prt.runtime.*;

public class AccessOne extends AbstractPortalComponent


public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)


IServiceOne myService =(IServiceOne)PortalRuntime.getRuntimeResources().getService(IServiceOne.KEY);

String s = myService.display();




/********************** Portalapp.xml ***********************/



<property name="SharingReference" value="ServiceProject"/>



<component name="AccessOne">


<property name="ClassName" value="com.sample.AccessOne"/>







<b>Right Click on the Portal Application --->Properties -> Java Build Path-> click on Libraries Tab on the Top and Click Add External Jars Tab on the Right ---> Add Your Portal Service PAR File</b> .

Now Deploy the Application.<i></i><u></u><i></i>

Reward Points if u find this useful.



Answers (1)

Answers (1)

0 Kudos

Hello Yogi,

When calling a service, It does not make any difference if it is in same project or in other project. <b>So there is only one Scenario, accessing a service</b>

It is ofcourse your Service.KEY that is very important for external components to access it. So let us see, how to define a KEY.

KEY can never be a class file name, as from logic this class can even be present in some other project/application which will create a conflict situation.

So the right KEY should be:

1. <b>ApplicationName</b>.<b>ServiceName</b>

2. <b>ApplicationAliasName.ServiceName</b>

ApplicationName = Parfilename

ApplicationAliasName = You can define application alias in portalapp.xml

So it should be Parfilename.servicename and not Parfilename|servicename


Praveen Gudapati

Former Member
0 Kudos

The line

<property name="SharingReference" value="serviceproject" /> fixed my problem in the calling application. If i am correct, it must be the name of the PAR file.. thats all.. you need not specify service name, alias etc.. in the sharingreference property.

Thanks for your help.


P.S: Points granted

Former Member
0 Kudos

I agree with Yogi. Because we reference the service name during lookup...