0

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());
		}
	}
}
3
Contributors
4
Replies
10
Views
5 Years
Discussion Span
Last Post by Traevel
0

Here is the error response from server:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'GetCountryByCountryCode' expects parameter '@CountryCode', which was not supplied.
at WebServicex.country.GetCountryByCountryCode(String CountryCode)
--- End of inner exception stack trace ---

how can I solve it ? any help for me !

1

@Ivan_15

I think you're better off creating a new question and tag it with Java to receive more help for your own specific problem. I'll add this though:

Apache Axis received its last update in 2006. Before trying to solve an issue with parameters I strongly suggest you update to Axis2. You can use the following migration guide to help you make the switch. There's really no point in trying to fix an error that's occuring in code that's been discontinued for over 10 years. Migrating might even solve your problem all on its own.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.