AxisClientProxypublic class AxisClientProxy extends Object implements InvocationHandlerVery simple dynamic proxy InvocationHandler class. This class is
constructed with a Call object, and then each time a method is invoked
on a dynamic proxy using this invocation handler, we simply turn it into
a SOAP request. |
Fields Summary |
---|
private Call | call | private QName | portName |
Constructors Summary |
---|
AxisClientProxy(Call call, QName portName)Constructor - package access only (should only really get used
in Service.getPort(endpoint, proxyClass).
Call can be pre-filled from wsdl
this.call = call;
this.portName = portName; // can be null
|
Methods Summary |
---|
private void | callOutputParams2proxyParams(java.lang.Object[] proxyParams)Copy in/out and out parameters (Holder parameters) back to proxyParams.
OperationDesc operationDesc = call.getOperation();
if (operationDesc == null)
{
// we don't know which parameters are IN, OUT or INOUT
// let's suppose they are all in
return;
}
Map outputParams = call.getOutputParams();
for (int i = 0; i < operationDesc.getNumParams();i++)
{
Object param = proxyParams[i];
ParameterDesc paramDesc = operationDesc.getParameter(i);
if ((paramDesc.getMode() == ParameterDesc.INOUT) ||
(paramDesc.getMode() == ParameterDesc.OUT)) {
JavaUtils.setHolderValue((Holder)param,
outputParams.get(paramDesc.getQName()));
}
}
| public Call | getCall()Returns the current call.
return call;
| public java.lang.Object | invoke(java.lang.Object o, java.lang.reflect.Method method, java.lang.Object[] objects)Handle a method invocation.
// first see if we invoke Stub methods
if (method.getName().equals("_setProperty")) {
call.setProperty((String) objects[0], objects[1]);
return null;
} else if (method.getName().equals("_getProperty")) {
return call.getProperty((String) objects[0]);
} else if (method.getName().equals("_getPropertyNames")) {
return call.getPropertyNames();
} else if (Object.class.equals(method.getDeclaringClass())) {
// if we invoke basic Object methods : delegate to Call instance
return method.invoke(call, objects);
} else {
Object outValue;
Object[] paramsCall;
if ((call.getTargetEndpointAddress() != null) &&
(call.getPortName() != null)) {
// call object has been prefilled : targetEndPoint and portname
// are already set. We complete it with method informations
call.setOperation(method.getName());
paramsCall = proxyParams2CallParams(objects);
outValue = call.invoke(paramsCall);
}
else if (portName != null)
{
// we only know the portName. Try to complete this information
// from wsdl if available
call.setOperation(portName,method.getName());
paramsCall = proxyParams2CallParams(objects);
outValue = call.invoke(paramsCall);
}
else
{
// we don't even know the portName (we don't have wsdl)
paramsCall = objects;
outValue = call.invoke(method.getName(), paramsCall);
}
callOutputParams2proxyParams(objects);
return outValue;
}
| private java.lang.Object[] | proxyParams2CallParams(java.lang.Object[] proxyParams)Map between the parameters for the method call and the parameters needed
for the Call .
Parameters for invoke method are not the same as parameter for Call
instance :
- Holders must be converted to their mapped java types
- only in and inout parameters must be present in call parameters
OperationDesc operationDesc = call.getOperation();
if (operationDesc == null)
{
// we don't know which parameters are IN, OUT or INOUT
// let's suppose they are all in
return proxyParams;
}
Vector paramsCall = new Vector();
for (int i = 0; proxyParams != null && i < proxyParams.length;i++)
{
Object param = proxyParams[i];
ParameterDesc paramDesc = operationDesc.getParameter(i);
if (paramDesc.getMode() == ParameterDesc.INOUT) {
paramsCall.add(JavaUtils.getHolderValue((Holder)param));
}
else
if (paramDesc.getMode() == ParameterDesc.IN) {
paramsCall.add(param);
}
}
return paramsCall.toArray();
|
|