Can you return an array from JAX-WS @WebMethod?

I'm sure you can, but besides answering the question in the title, could you also explain the pros, cons, caveats, if any, do it? I know you cannot return a list, set, collection, map, or any interface from a WebMethod (this is silly IMO, but I don't know what the design reasons were, should I probably give up judgment).

Thanks for any advice.

- LES

+2


source to share


2 answers


You can return arrays and I found them helpful.

The main reason assemblies are a problem is because some languages, like C, don't understand the concept of a collection, so in order to remain portable you need to skip the structures that most languages ​​might represent.



Also, I am never a fan of passing collections, since what comes from a web service should be pretty static. If you want to add to it, then convert the array to collection, then pass the array to the web service to make the changes.

+3


source


James is right, you can return arrays. You can also return collection types. Wsdl will define the type as a list. However, most clients convert the type to array (at least that's what I found C # did with JAX-WS service).

I used a third party group (Apache Axis2) to create a web service and I ran into an odd problem where the wsdl was not read correctly and the array could not be deserialized correctly by the consumer. It was necessary to create a decorator object that contained only an array object and was returned from a web method.



I think this is just Axis2 not playing very well with the .NET web service interfacing, but a little something to be aware of.

+1


source







All Articles