I was wondering if it is possible to make a generic webservice method in java like this:
@WebMethod
public <T extends Foo> void testGeneric(T data){
However when I try to consume this with a Java client I get an error stating:
[ERROR] Schema descriptor {http://####/}testGeneric in message part "parameters" is not defined and could not be bound to Java.
I know it is possible to make a method that takes a parameter such as List and this generates correctly using JAX-WS.
I don't mind if there is a solution that means I am tied开发者_C百科 to using only a particular technology.
Thanks, Dan.
I doubt it. But you can define a generic super interface and let your actual service interface extend it with parameters:
public interface BaseService<T>{
T doWhackStuff();
}
public interface WhackyService extends BaseService<Whack>{
}
public interface EvenMoreWhackyService extends BaseService<Whackier>{
}
This approach usually only makes sense if you build your interfaces from multiple components:
public interface BaseService<T>{
T doWhackStuff();
}
public interface ExtendedService<T>{
T doMoreWhackStuff();
}
public interface DoubleWhackyService extends BaseService<Whack>, ExtendedService<Whack>{
}
I have not tested this approach in JAX-WS, but I know it works in Spring / GraniteDS / Flex
精彩评论