有Jax-Ws Web服务方法获得20个参数。参数应该被验证,所以我必须将它们全部传递给另一个验证器方法,或者通过将参数传递给构造函数来创建类对象,然后使用该对象来调用验证器方法
这是一个例子
WebService接口对象
public interface IEcommWs {
@WebMethod
@RequestWrapper(localName = "payment", className = "ge.jibo.ecomm.ws.wrapper.PaymentRequest")
@ResponseWrapper(localName = "paymentResponse", className = "ge.jibo.ecomm.ws.wrapper.PaymentResponse")
public void payment(@WebParam(name = "requestType", mode = Mode.IN) RequestType requestType,
@WebParam(name = "merchantId", mode = Mode.IN) String merchantId,
.... another 20 param ....
@WebParam(name = "response", mode = Mode.OUT) Holder<Response> response,
@WebParam(name = "paymentResult", mode = Mode.OUT) Holder<PaymentResult> paymentResult);
}
和实施
@WebService(endpointInterface = "ge.jibo.ecomm.ws.IEcommWs")
public class EcommWs implements IEcommWs {
@Override
public void payment(RequestType requestType, String merchantId,
.... another 20 param ....
Holder<Response> response,
Holder<PaymentResult> paymentResult) {
Validator.validateInput(RequestType requestType, String merchantId, .... another 20 param ....);
or
PaymentRequest requestParams = new PaymentRequest(RequestType requestType, String merchantId, .... another 20 param ....);
Validator.validateInput(requestParams);
}
我可以在不使用类构造函数的情况下在一个对象中转换所有这些参数吗?
像这样PaymentRequest requestParams = getPaymentMethodParams();