Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

call session bean from java program  RSS feed

 
david lightman
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am experimenting and I have websphere studio application developer 5.1.2 and I have successfully created a stateless session bean that simple writes a println to the SystemOut with my test server.

I would like to write a little java gui that can call the method in the session bean from another computer.

what does this entail?
do i need web services?

where should i go to learn how to do this?

thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

what does this entail?

You will need to :
  • Get an InitialContext (your server documentation probably has an example)
  • Lookup your bean's JNDI name in that context
  • Use PortableRemoteObject's narrow method to get your bean's home interface
  • Call the create method on tha thome interface



  • do i need web services?

    No.


    where should i go to learn how to do this?

    There is a tutorial at Sun which covers the basics. Other than that, examples are peppered around these forums. Have a search.
     
    david lightman
    Ranch Hand
    Posts: 82
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks for the reply. that makes sense what you said. I actually have an MDB doing exactly what you stated and it calls the session bean great. But I am confused about how to use a plain old java program 'outside' of the websphere to call this session bean. How would my java program know anything about the session bean on the server?
     
    Dan Bizman
    Ranch Hand
    Posts: 387
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There are two things involved here:

    1. You create an initial context that tells it where to find the server

    ( for example... )


    You would replace "myserver.com" with the address of the server hosting the session bean.

    2. You must have all the required interfaces.

    For example, if your session bean has the remote home: MySessionRemoteHome
    then you'll need that interface on the client side's classpath.

    That's basically it!
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!