Reputation: 14479
public class Pojo {
private String value;
public static void printValue() {
System.out.println("value=" + value);
}
}
I would want to return this from a web service as follows:
@WebService
public class MyService {
@WebMethod
public Pojo getPojo() {
return new Pojo();
}
}
Can't seem to find the definitive answer on whether I can, should, can't, or shouldn't.
Upvotes: 0
Views: 1260
Reputation: 18336
Only data are sent over the wire. Static or non-static methods are not sent.
If on the receiving side you bind the data to the same class -- fine, you have your methods back, but SOAP has nothing to do with it, it's your own trickery. Clients written in other languages (C#, python, ...) won't have your method, of course.
P.S. The class of any object you're sending back always has methods. Your Pojo is implicitely subclassed from Object, and thus have toString(), hashCode(), and so on. JAX-WS doesn't care.
Upvotes: 2
Reputation: 139931
No. Think about it:
So how would you be able to send across the wire a static method? How would non-Java clients be able to interpret your web service's response?
Upvotes: 1