cancel
Showing results for 
Search instead for 
Did you mean: 

How to call Methods in Remote SessionBean

Former Member
0 Kudos

Hi,

I have to access Methods in SessionBean which is living in Another Server .

I Know how to access ejbs which are living in same server but i do't Know how to access remote ejbs.

<b>i am working on NetWeaverDeveloperStudio</b>

Please send me code if possible.

Regards

Guru

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182372
Active Contributor
0 Kudos

Hi Guru,

For "HelloStatelessBean" bean code looks like


final Properties _param = new Properties();

_param.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");
_param.put(Context.PROVIDER_URL, "<HOST_NAME>:<MESSAGE_PORT(For my case - 50204)>");
_param.put(Context.SECURITY_PRINCIPAL, "<USER_NAME>");
_param.put(Context.SECURITY_CREDENTIALS, "<USER_PASSWORD>");

final Context initialContext = new InitialContext(_param);

final Object obj = initialContext.lookup("sap.com/Hello/Stateless/HelloStatelessBean");
final HelloHome helloHome = (HelloHome)PortableRemoteObject.narrow(obj, HelloHome.class);
final Hello hello = helloHome.create();

System.out.print(hello.getMessage());

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Guruvulu,

You can use the EJBs as similar to any other app server in SAP webAS as well.

Please refer to the following two links, if you are familiar a bit with J2EE and EJB then you will certainly be able to solve your problem with them,

http://java.sun.com/developer/onlineTraining/J2EE/Intro2/session_bean/session.html

http://www.unix.org.ua/orelly/java-ent/ebeans/ch07_01.htm

Hope that helps,

Guru.

P.S. : by the way i am also called guru