我创建了一个Web服务并运行一个简单的计算器程序,如下所示:
public void sumAndMultiply(int a, int b,
@WebParam(name = "joda", mode = WebParam.Mode.OUT) Holder<Integer> sum,
@WebParam(name = "ghatak", mode = WebParam.Mode.OUT) Holder<Integer> multiply) {
sum.value = a + b;
multiply.value = a * b;
}
}
为此,我将<arg0>
和<arg1>
的值a和b发送为:
<arg0> 4 </arg0>
<arg1> 5 </arg1>
我应该在代码中修改什么来更改参数名称,以便我需要发送请求,如:
<firstnumber>4</firstnumber>
<secondnumber>5</secondnumber>
答案 0 :(得分:1)
使用每个输入变量前面的@WebParam(name="")
。
@WebMethod
public void sumAndMultiply(@WebParam(name = "firstnumber") int a,
@WebParam(name = "secondnumber") int b) {
// some stuff here
}
public void sumAndMultiplyAndReference
(@WebParam(name = "firstnumber")int a,
@WebParam(name = "firstnumber")int b,
@WebParam(name = "referencenumber")int c
@WebParam(name = "sum", mode = WebParam.Mode.OUT) Holder<Integer> sum,
@WebParam(name = "multiply", mode = WebParam.Mode.OUT) Holder<Integer> multiply,
@WebParam(name = "reference", mode = WebParam.Mode.OUT) Holder<Integer> reference){
sum.value = a + b;
multiply.value = a * b;
reference.value = c;
}
public void sumAndMultiplyAndReference
(@WebParam(name = "firstnumber", mode = WebParam.Mode.IN)int a,
@WebParam(name = "firstnumber", mode = WebParam.Mode.IN)int b,
@WebParam(name = "referencenumber", mode = WebParam.Mode.IN)int c
@WebParam(name = "sum", mode = WebParam.Mode.OUT) Holder<Integer> sum,
@WebParam(name = "multiply", mode = WebParam.Mode.OUT) Holder<Integer> multiply,
@WebParam(name = "referencenumber", mode = WebParam.Mode.OUT) Holder<Integer> referencenumber){
sum.value = a + b;
multiply.value = a * b;
referencenumber.value = c;
}