NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Webservice with generic methods

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
danby



Joined: 10 Mar 2010
Posts: 4

PostPosted: Mon May 17, 2010 10:44 am    Post subject: Webservice with generic methods Reply with 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
mkuchtiak
Posted via mailing list.





PostPosted: Thu May 20, 2010 8:26 pm    Post subject: Re: Webservice with generic methods Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo