Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.apache.axis.client.Call 's invoke method

 
Bharat Macwana
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created one web service in eclipse which returns sum of two int as follows
public int Adder(int a, int b){return a+b;}

now following code is generated in stub when i create client...., in this code, invoke
method takes Array of Object, which contains two int to sum up. Can anyone tell me how
invoke will call Adder method in my webservice and how it will extract those two int from
Object Array and how it will pass those int to Adder() method,,

public int add(int in0, int in1) throws java.rmi.RemoteException {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
}
org.apache.axis.client.Call _call = createCall();
_call.setOperation(_operations[0]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("");
_call.setEncodingStyle(null);
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
_call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
_call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("http://test.soa.bang.ind", "add"));

setRequestHeaders(_call);
setAttachments(_call);
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {new java.lang.Integer(in0), new java.lang.Integer(in1)});

if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
}
else {
extractAttachments(_call);
try {
return ((java.lang.Integer) _resp).intValue();
} catch (java.lang.Exception _exception) {
return ((java.lang.Integer) org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
}
}
} catch (org.apache.axis.AxisFault axisFaultException) {
throw axisFaultException;
}
}
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Although the invoke method takes an array, that's not how the parameters are sent across the wire. Somewhere in the stub files the proper SOAP is created which sends those individually as the parameters. It's just that the invoke method takes an array parameter so that it can accommodate any number of parameters.

I recommend you use a tool like tcpmon (which is part of Axis, and explained in its documentation) to watch the SOAP that gets sent over the wire; it's instructive to see what goes on underneath.
 
Bharat Makwana
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ulf Dittmer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic