• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can my web service class implement an interface

 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic