The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: convert Session EJB to web service

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 8 - Last Post: Aug 27, 2007 2:02 AM by: javaisfun
javaisfun

Posts: 3
convert Session EJB to web service
Posted: Aug 22, 2007 2:11 AM
 
  Click to reply to this thread Reply

Are there any tools available to convert Session EJB, j2ee application to web service in Sun Application Server. I am looking for something similar to servicegen of weblogic.

arungupta

Posts: 49
Re: convert Session EJB to web service
Posted: Aug 22, 2007 1:17 PM   in response to: javaisfun
Helpful
  Click to reply to this thread Reply

I added @WebService to a session EJB and, rebuilt and redeployed the project and it converted my EJB into a Web service.

For the code given below:

-- cut here --
@Stateless
@WebService
public class HelloSessionBean implements server.HelloSessionLocal {

/** Creates a new instance of HelloSessionBean */
public HelloSessionBean() {
}

public String sayHello(String name) {
return "Hello " + name + " from session bean";
}
}
-- cut here --

the Web service endpoint was hosted at: http://localhost:8080/HelloSessionBeanService/HelloSessionBean?wsdl

webservices.xml is optional per JSR 109 MR2. JAXB provides 100% XML Schema support and allows serializing any Javabeans-style classes.

Is there something more to it ?

Dies Koper
Re: convert Session EJB to web service
Posted: Aug 22, 2007 5:22 PM   in response to: arungupta
  Click to reply to this thread Reply

Yes, on the server side that's it.
Just be careful not to deploy a WAR module with a context root like the
one generated for your Web service endpoint below. GlassFish will let
you do it without warning, and your endpoint will become inaccessible to
your clients (HTTP Status 500 - WEB0502: No ad-hoc servlet configured to
process ad-hoc path), replaced by the new servlet app.


glassfish@javadesktop.org wrote:
> I added @WebService to a session EJB and, rebuilt and redeployed the project and it converted my EJB into a Web service.
>
> For the code given below:
>
> -- cut here --
> @Stateless
> @WebService
> public class HelloSessionBean implements server.HelloSessionLocal {
>
> /** Creates a new instance of HelloSessionBean */
> public HelloSessionBean() {
> }
>
> public String sayHello(String name) {
> return "Hello " + name + " from session bean";
> }
> }
> -- cut here --
>
> the Web service endpoint was hosted at: http://localhost:8080/HelloSessionBeanService/HelloSessionBean?wsdl
>
> webservices.xml is optional per JSR 109 MR2. JAXB provides 100% XML Schema support and allows serializing any Javabeans-style classes.
>
> Is there something more to it ?
> [Message sent by forum member 'arungupta' (arungupta)]
>
> http://forums.java.net/jive/thread.jspa?messageID=232117
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


arungupta

Posts: 49
Re: convert Session EJB to web service
Posted: Aug 23, 2007 6:18 AM   in response to: Dies Koper
Helpful
  Click to reply to this thread Reply

I summarized the solution at:

http://blogs.sun.com/arungupta/entry/totd_4_how_to_convert

Dies Koper
Re: convert Session EJB to web service
Posted: Aug 23, 2007 6:35 AM   in response to: arungupta
  Click to reply to this thread Reply

Very nice!
How about adding a link to a page (or writing one) how to write a client
that can access this bean through its endpoint?

BTW: when I undeployed the WAR that made my endpoint inaccessible it ran
again as before. I then deployed it again to show what happens to my
colleague and guess what? Both were accessible! Looks like RC3 might
have a quirk or two left.
#Shared context? I hope the person who designed that confirmed that that
has no bad consequences to servlet mapping or security settings in the
servlet module. It's late, I am not not going to try to figure it out. ;)

glassfish@javadesktop.org wrote:
> I summarized the solution at:
>
> http://blogs.sun.com/arungupta/entry/totd_4_how_to_convert
> [Message sent by forum member 'arungupta' (arungupta)]
>
> http://forums.java.net/jive/thread.jspa?messageID=232292


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


Arun Gupta
Re: convert Session EJB to web service
Posted: Aug 23, 2007 9:29 AM   in response to: Dies Koper
  Click to reply to this thread Reply

Dies,

See in line ...

> How about adding a link to a page (or writing one) how to write a client
> that can access this bean through its endpoint?
The nice thing about Web services is that the client and service are
completely independent of each other.

This Web service can be invoked using any of the mechanisms described at:

http://blogs.sun.com/arungupta/entry/screencast_ws2_invoking_a_web

>
> BTW: when I undeployed the WAR that made my endpoint inaccessible it ran
> again as before. I then deployed it again to show what happens to my
> colleague and guess what? Both were accessible! Looks like RC3 might
> have a quirk or two left.
I have not experimented with this but do let me know what you find out.

Thanks,
-Arun

> #Shared context? I hope the person who designed that confirmed that that
> has no bad consequences to servlet mapping or security settings in the
> servlet module. It's late, I am not not going to try to figure it out. ;)
>
> glassfish@javadesktop.org wrote:
>> I summarized the solution at:
>>
>> http://blogs.sun.com/arungupta/entry/totd_4_how_to_convert
>> [Message sent by forum member 'arungupta' (arungupta)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=232292
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

--
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


javaisfun

Posts: 3
Re: convert Session EJB to web service
Posted: Aug 26, 2007 9:58 PM   in response to: Arun Gupta
 
  Click to reply to this thread Reply

I want to know something more. My problem is that I already have session beans so are there any conversion tools to convert these session beans to web services eligible beans.

I wanted to know about a tool that may append @WebService to my already existing beans to compile and convert them to be used for web services clients.

whartung

Posts: 634
Re: convert Session EJB to web service
Posted: Aug 26, 2007 10:34 PM   in response to: javaisfun
Correct
  Click to reply to this thread Reply

Umm...

All you need to do (for basic functionality) is add @WebService to each bean, and then redeploy it. All of the work is done during the deployment by the container. There isn't really much to convert. And anything outside of the defaults would need to be specified directly within the Session Bean code anyway, there's really not much work for a tool (beyond a simple bulk handling script of somekind) to do here.

javaisfun

Posts: 3
Re: convert Session EJB to web service
Posted: Aug 27, 2007 2:02 AM   in response to: whartung
 
  Click to reply to this thread Reply

Yes this is a solution but I was just wondering why there is not something parallel to servicegen of weblogic in Sun Appserver




 XML java.net RSS