aspose file tools*
The moose likes Web Services and the fly likes JAXWS client erroring out when calling a stateless session bean exposed as a webservice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "JAXWS client erroring out when calling a stateless session bean exposed as a webservice" Watch "JAXWS client erroring out when calling a stateless session bean exposed as a webservice" New topic
Author

JAXWS client erroring out when calling a stateless session bean exposed as a webservice

Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

Hello,

I have deployed a Stateless Session bean as a webservice in Glassfish. I'm using JAXWS client to call the business method on the web service as follows:


The HelloBean webservice is as follows:


I get the following exception when running the client:


I'm unable to figure out why it is expecting an Interface. I'm running the example from Mastering EJB 4th edition Chap 5. Can anyone please advise.

Thanks,
Allen
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hello!
It looks like you have forgotten to add the endpointInterface element to the @WebService annotation.
I think it should look like this:

Note that the endpoint interface must also be annotated with the @WebService annotation.
Hope this helps!
Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

Thanks. That worked. I also had to change to

Allen
Chintan Rajyaguru
Ranch Hand

Joined: Aug 19, 2001
Posts: 341
Since your code is working, you might not care but I would like to clarify something.

When you use dynamic proxy, you have no generated code. So, when you use the code service.getPort (Class<T> endpointInterface), YOU need to supply an INTERFACE that the dynamic proxy can implement. This interface must conform to the port type defined in the WSDL. In your case, you were passing a class as opposed to an interface, that's why you got the error. The getPort() method needs an interface, see the API javadoc here.

The easiest way to get the interface is to use the remote interface you have already defined for your EJB. Make sure the interface is packaged with the client and is available in the runtime classpath.

The more interesting questions is, what if you had a POJO based web service? The JAX-WS specification says if [minimally] a class has @WebService annotation, all of its methods must be exposed as a web service and an interface must be generated and used dynamically at runtime. In this scenario, you have no interface. How would you write a client? Or what if your web service is written in .Net and you want to write dynamic client. Where would you get the interface from and how would you invoke the service?

Well, you have two choices: (1) Generate and use static client. In your example, it would generate a class GreeterService.java or something like that. This class will have a method getXYZPort(). You can use this method to get the port and invoke the service on it. (2) Generate code, which among other things will generate an interface. Write a dynamic client and pass this interface to your getPort() method. The limitation in this case would be that you still have to 'generate' client side code.

I consider this issue a lack of completeness in the JAX-WS specification. If the specs allow a POJO web service without an interface, it should also allow a dynamic client without an interface. As long as you pass the port name and namespace, it should automatically generate the endpoint interface at runtime. Unfortunately, that's not how it works.

ChintanRajyaguru.com
SOADevelopment.com - Coming soon!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Thanks Chintan!
It was a very interesting message!
Best regards!
Allen Bandela
Ranch Hand

Joined: Feb 16, 2006
Posts: 128

I did have this question in the back of my mind. Thanks for clarifying.

In your comment, you speify twice to generate code
(1) Generate and use static client.
.
(2) Generate code, which among other things will generate an interface


How to generate. By using tools and the wsdl? I guess I'll learn about this as I read further in the book..
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Yes, JAX-WS contains the wsgen and wsimport tools which are used to generate misc. artifacts.
Check this webpage: http://www.j2ee.me/webservices/docs/2.0/jaxws/jaxws-tools.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JAXWS client erroring out when calling a stateless session bean exposed as a webservice
 
Similar Threads
can not deploy application!!!!
Generate stubs for EJB3.1 bean exposed as webservice
stateless session as a webservice
JBOSS web service client doesn't work ( runtime modeler error: Wrapper class not found )
Problem creating a dummy web service w/ WS-RM