NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
danby
Joined: 10 Mar 2010 Posts: 4
|
Posted: Mon May 17, 2010 10:44 am Post subject: Webservice with generic methods |
|
|
Hi,
I would like to make a Web service method such as:
@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.
Is it possible to make a generic web service as such? I can make methods which use List<String> etc and this generates fine using JAX-WS. I don't care if the solution means that I am tied to using only Java and JAX-WS for consuming this web service.
Any help would be much appreciated,
Dan. |
|
| Back to top |
|
 |
mkuchtiak Posted via mailing list.
|
Posted: Thu May 20, 2010 8:26 pm Post subject: Re: Webservice with generic methods |
|
|
What's the advantage of using
@WebMethod
public <T extends Foo> void testGeneric(T data) {}
instead of
@webMethod
public void testGeneric(Foo data) {} ?
Note: in JAX-WS you can not use interface as parameter/return type.
Except of that, the Foo class must adhere some rules, e.g. must have empty constructor, etc.
Anyway, on the client side you can extend Foo class and pass the instance of such a class to web service.
On the other hand I don't see a big advantage of that since the SOAP message will be restricted to the signature specified by superclass only.
Note also that the instance of Foo must be marshaled (to XML) into SOAP request.
Milan
danby wrote:
| Quote: | Hi,
I would like to make a Web service method such as:
@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.
Is it possible to make a generic web service as such? I can make methods which use List<String> etc and this generates fine using JAX-WS. I don't care if the solution means that I am tied to using only Java and JAX-WS for consuming this web service.
Any help would be much appreciated,
Dan.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|