简体   繁体   中英

How to invoke a webservice with holders as parameters in jax-ws

I am new to jax-ws development and I have generated java source files from a wsdl using wsimport. And I need to call a function from one of these source files into my UI program.

The function I need to call looks like:

@WebMethod(operationName = "GetX")
@RequestWrapper(localName = "GetX", targetNamespace = "urn:Control", className = "jaxws.control.GetX")
@ResponseWrapper(localName = "GetXResponse", targetNamespace = "urn:Control", className = "jaxws.control.GetXResponse")
public void myHostGetX(
    @WebParam(name = "isActive", targetNamespace = "", mode = WebParam.Mode.OUT)
    Holder<Boolean> Active);

Lets say the this funtion is part of a class called Class A.

But if I try invoking this by doing something like,

boolean foo;
ResponseFromWS response = myHostGetX(foo); 

I get an error like,

The method myHostGetX(Holder<Boolean>) in the type Class A is not applicable for the arguments (boolean)

How can I call this Holder<Boolean> ?

You need to set the value of the holder. So either:

myHostGetX(new Holder(Boolean.TRUE)); //note plain boolean should work in the constructor.

OR

myHostGetX(new Holder()); 

OR

Holder holder = new Holder();
holder.value = Boolean.TRUE;
myHostGetX(holder)

Any of those should work. It's worth mentioning that since this is an OUTPUT parameter, the setting of the value should occur within the implementation of that method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM