Invoking .net webservice from Axis client
843833Jun 24 2005 — edited Jul 19 2005Hi
I have simple .net webservice which adds 2 numbers (int). I am trying to invoke it from a axis client using a small java code. It returns me the output as 0 for ints and null if i try to work with strings.
I am not sure if this is because of datatype mismatch or for some other reason. It gives no error messages. This is the code below:
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import java.net.URL;
public class InvokeClient1 {
public static void main(String [] args)
{
try {
String endPoint = "http://localhost/WSTest/AddTest.asmx?WSDL";
Service service = new Service();
Call call = (Call) service.createCall();
call.setProperty(call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(call.SOAPACTION_URI_PROPERTY, "http://localhost/WSTest/AddTest.asmx/AddNumbers");
call.setTargetEndpointAddress( new java.net.URL(endPoint));
call.setOperation( "AddNumbers" );
Integer i1 = new Integer(2);
Integer i2 = new Integer(3);
call.addParameter("arg0",XMLType.XSD_INT, ParameterMode.IN);
call.addParameter("arg1",XMLType.XSD_INT, ParameterMode.IN);
call.setReturnType(XMLType.XSD_INT);
Integer ret = (Integer) call.invoke( new Object [] { i1, i2 });
System.out.println("result: " + ret);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Please help
Regards
nt