views:

309

answers:

1

Hi I am use JAX-WS to make a web service. As parameters I am taking in two strings and an array of a objects whose type are a class in my project.

I have the webservice interface and implementation created and it is similar to this:

@WebMethod(operationName = "getStuff")
@WebResult(name = "result")
 Mix getStuff(
    @WebParam(name = "string1") String one,
    @WebParam(name = "string2") String two,
    @WebParam(name = "stuff") Stuff[] stuff
);

I am returning an object of type Mix which is a class in my project and I am accepting an array of type Stuff which is another class in my project. Testing from java is not a problem however when someone else attempts to consume the service or I try to send in a request with soapUI the array is always coming in null. What do I need to do so whomever is consuming my service can correctly send in the array of type Stuff? Do I need to do some customization with JAXB?

A: 

JAXB2 uses lists and not arrays, so you should replace the signature to

@WebMethod(operationName = "getStuff")
@WebResult(name = "result")
 Mix getStuff(
    @WebParam(name = "string1") String one,
    @WebParam(name = "string2") String two,
    @WebParam(name = "stuff") java.util.List<Stuff> stuff
);

Also, make sure that Mix and Stuff have JAXB annotations.

David Rabinowitz
I'm reasonably certain that this posting is not correct, at least in CXF. Note that since we're talking about the params, we're talking JAX-WS, not JAXB. JAX-WS will handle arrays, and there's absolutely no requirements to have any JAXB annotations on POJO's used as parameters or return values.
bmargulies
-1 As stated by @bmargulies this does not work!
Martin Olsen