What do I need to do to accept an array parameter in webservice?
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 = "stri开发者_如何转开发ng1") 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?
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.
精彩评论