Hi Everybody !
I'm using Apache Axis to invoke web service from internet. I can access a web service wherein no input parameters are required , but whenever I have to pass input parameters, I can't invoke it. Can somebody help me to figure out the problem. Here is my code below:
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
public class myClient {
public static void main (String[] args){
try{
String endpoint = "http://www.webservicex.net/country.asmx?wsdl";
Service service = new Service();
Call call = (Call)service.createCall();
call.removeAllParameters();
call.setTargetEndpointAddress( new java.net.URL(endpoint));
call.setOperationName(new QName("http://www.webserviceX.NET/GetCountryByCountryCode", "GetCountryByCountryCode"));
call.setProperty(javax.xml.rpc.Call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(javax.xml.rpc.Call.SOAPACTION_URI_PROPERTY, "http://www.webserviceX.NET/GetCountryByCountryCode");
call.addParameter("CountryCode", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnTypeAsHeader(XMLType.XSD_STRING);
Object[] inParams = new Object[]{"us"};
String result = (String)call.invoke(inParams);
System.out.println(result);
}catch(Exception e){
System.err.println(e.toString());
}
}
}