Arrays in SOAP Method Parameters generated via JAX-WS?

I am creating a SOAP service in Java with JAX-WS annotations. Among other things, I'm wondering how to comment out array parameters in my methods. The moment I generate a wsdl from my annotated interface and then generate Java classes from that wsdl again (I am doing this for testing, in both cases using Apache cxf), it will generate classes to store the array parameters.


@SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL, parameterStyle=SOAPBinding.ParameterStyle.BARE)
public interface SillyService {
    public String doSillyThings(
         @WebParameter(name = "stupid") StupidData[] stupid;


Where StupidData would be another class annotated in this way


@XmlRootElement(name = "StupidData")
public class StupidData {
@XmlElement(name = "datapoint")
String datapoint;


Then, instead of an array in the generated classes, the Parameter becomes a new StupidDataArray class that has a file that is a StupidData array.

How do I make it take an array as a parameter directly? Thank...


source to share

1 answer

In my case, the code generated by apache CXF from WSDL files includes classes ArrayOfXXX

, with one method getXXX()

returning List

. The autogenerated javadoc of this method reads:

This accessor returns a link to a live list, not a snapshot. Therefore, any changes you make to the returned list will be present inside the JAXB object. Therefore, there is no method for the guid property set

. For example, to add a new item, do the following: <Code> getXXX () add (newItem) ;.

To answer your question, you cannot pass your own array to a method, but you can pass an Array class after you add items to its main list. To do this, you extract the encapsulated List

array from the wrapper with getXXX()

and add elements to it.



All Articles