File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes how can my web service class implement an interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "how can my web service class implement an interface" Watch "how can my web service class implement an interface" New topic
Author

how can my web service class implement an interface

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
I am not able to write :
webserviceclass implements interface

I am using servicegen script to convert java file to the web service.But then also,if i add
javaClassComponents="javaclass1,interface1"

It is saying interface1 does not have any no arg constructor,so can't used in the web service.
kindly tell how can i code my web service to implement an interface.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41186
    
  45
Why would having the service class implement an interface be a useful feature? The lifecycle of the class is under the control of the WS engine, which only cares about the methods inside of the class, not any interface it may implement.


Ping & DNS - my free Android networking tools app
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
but a class or interface can be exposed as a web service only if it has one no-arg constructor that is what i have read on google.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41186
    
  45
An interface can't possibly be exposed as a WS, because it contains no code (and no constructors, but that is irrelevant).

If you thought that you needed to expose an interface you might have misunderstood what was going on. If you described the situation where this issue came up we might be able to clear that up.
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
i just have a .java file which will exposed as a web service.this .java file needs to implement an interface.i am making this java file as a web service through servicegen script and service tag.but,i am not able to use the interface
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41186
    
  45
Why does it need to implement an interface? Are you using it somewhere else in addition to it being a WS? In that case, consider creating an additional class for the WS which has the same methods and does nothing but pass the calls through to the class implementing the interface.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9963
    
163

Going by the javaClassComponents attribute of the servicegen task:

javaClassComponents:
Comma-separated list of Java class names that implement the Web Service operation. The Java classes must be compiled and in your CLASSPATH.

For example:

javaClassComponents="my.FirstClass,my.SecondClass"

Note: Do not include the .class extension when specifying the class names.

The servicegen Ant task introspects the Java classes to automatically generate all the needed components.


The values for that javaClassComponents attribute are supposed to be comma separated list of java class and NOT interfaces. So you are not supposed to mention the interface name in that comma separated list. When you do specify that interface in that list, the servicegen task is considering it a class instead of an interface.


[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how can my web service class implement an interface
 
Similar Threads
Please HELP...Devaka Exam Test 2 Number 69. I totally don't understand it.
Nested Interface - Real-World Example?
K & B SCJP5 Page77
how to implement two different definition for class which implements two interface with same method
Java and Generics