简体   繁体   English

如何在jax-ws中使用持有人作为参数调用Web服务

[英]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. 我是jax-ws开发的新手,并且已经使用wsimport从wsdl生成了Java源文件。 And I need to call a function from one of these source files into my UI program. 而且我需要从这些源文件之一调用函数到我的UI程序中。

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. 可以说,此功能是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> ? 我怎么称呼这个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. 值得一提的是,由于这是一个OUTPUT参数,因此该值的设置应在该方法的实现中进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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