File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can my web service class implement an interface

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 418
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic