最近,我尝试使用基于Axis的maven插件基于RPC WebService的WSDL生成存根。过去,我曾使用Jax和SOAP WebServices一起工作过,并且有点与Axis生成的Java Stub混淆了。
它们看起来像:
public interface PowerTest extends Service {
String getPowerTestPortAddress();
PowerTestRPC getPowerTestPort() throws ServiceException;
PowerTestRPC getPowerTestPort(URL var1) throws ServiceException;
}
---------------------------------------------------------- (another class)
public class PowerTestBindingStub extends Stub implements PowerTestRPC {
private Vector cachedSerClasses;
private Vector cachedSerQNames;
private Vector cachedSerFactories;
private Vector cachedDeserFactories;
static OperationDesc[] _operations = new OperationDesc[139];
private static void _initOperationDesc1() {
OperationDesc oper = new OperationDesc();
oper.setName("WS_ConfirmStock");
ParameterDesc param = new ParameterDesc(new QName("", "Entrada1"), (byte)1, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
oper.addParameter(param);
param = new ParameterDesc(new QName("", "Resultado"), (byte)2, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
oper.addParameter(param);
param = new ParameterDesc(new QName("", "Salida1"), (byte)2, new QName("http://www.4d.com/namespace/default", "ArrayOffloat"), float[].class, false, false);
oper.addParameter(param);
oper.setReturnType(XMLType.AXIS_VOID);
oper.setStyle(Style.RPC);
oper.setUse(Use.ENCODED);
_operations[0] = oper;
oper = new OperationDesc();
oper.setName("WS_ConfirmarClienteMayor");
param = new ParameterDesc(new QName("", "Entrada1"), (byte)1, new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, false, false);
oper.addParameter(param);
public void WS_ConfirmStock(String entrada1, StringHolder resultado, ArrayOffloatHolder salida1) throws RemoteException {
if (super.cachedEndpoint == null) {
throw new NoEndPointException();
} else {
Call _call = this.createCall();
_call.setOperation(_operations[0]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("PowerTest#WS_ConfirmarStock");
_call.setSOAPVersion(SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new QName("http://www.4d.com/namespace/default", "WS_ConfirmarStock"));
this.setRequestHeaders(_call);
this.setAttachments(_call);
try {
Object _resp = _call.invoke(new Object[]{entrada1});
if (_resp instanceof RemoteException) {
throw (RemoteException)_resp;
} else {
this.extractAttachments(_call);
Map _output = _call.getOutputParams();
try {
resultado.value = (String)_output.get(new QName("", "Resultado"));
} catch (Exception var9) {
resultado.value = (String)JavaUtils.convert(_output.get(new QName("", "Resultado")), String.class);
}
try {
salida1.value = (float[])((float[])_output.get(new QName("", "Salida1")));
} catch (Exception var8) {
salida1.value = (float[])((float[])JavaUtils.convert(_output.get(new QName("", "Salida1")), float[].class));
}
}
} catch (AxisFault var10) {
throw var10;
}
}
因此,我们有2个主要类,一个是具有WS操作的“ bindingStub”,另一个是具有一些用于建立与Web服务的连接的方法的“定位器”?
为了正确使用这种WS,我必须遵循哪些步骤?