I'm new to web services and I created a basic project in eclipse with one exposed method. I was able to deploy my webservice and it works fine. The code is below.
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService(targetNamespace="http://test.com", name="testService")
public class WebService {
@WebMethod(operationName="start")
public String start(@WebParam(name="inputParameter") String inputParameter) {
return startMethod(inputParameter);
}
}
My question is how do I set up this method to deal with complex types. I want to receive a number of parameters, but I don't want to just receive them as a bunch of strings. I was thinking of having some sort of wrapper object that contained all the parameters I need for my method. Any advice on how to do this? Do I need additional annotations to create the WSDL? Thanks!
JAX-WS is based on JAXB so you can pass only JAXB supported types as a web method parameters. So any user defined class properly annotated such as mentioned below can be used as parameter or return type of any WebMethod
First, setup what complex types your webservice call or response contains in your WSDL
and then define what your complex types contains:
On the Java-side you need a wrapper class that contain these fields with getters and setters