I'm calling asmx service from android using ksoap library also I'm passing some parameters to that service but I'm getting all parameters EMPTY (i.e. "") in service definition. If I print request object in my android code before calling asmx service it is showing correct value, but getting empty parameters in service definition.
***My Android code is--***
public final String WSDL_TARGET_NAMESPACE = "http://www.example.com/abc/";
public final String SOAP_ADDRESS = "http://www.example.com/abc/WS.asmx";
public final String TEST_OPERATION="ServiceName";
public final String TEST_SOAP_ACTION="http://www.example.com/abc/ServiceName";
public String ServiceName(String strParam1, String strParam2)
{
***// following Log printing correct value***
Log.w("*******", "strParam1= "+strParam1+", strParam2= "+strParam2);
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,TEST_OPERATION);
PropertyInfo pi=new PropertyInfo();
pi.setName("strParam1");
pi.setValue(strParam1);
pi.setType(String.class);
request.addProperty(pi);
pi=new PropertyInfo();
pi.setName("strParam2");
pi.setValue(strParam2);
pi.setType(String.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
***// Following statement printing correct value***
Log.w("request= ", request.toString());
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
Object response=null;
try
{
httpTransport.call(TEST_SOAP_ACTION, envelope);
response = envelope.getResponse();
}
catch (Exception exception)
{
response=exception.toString();
}
return response.toString();
}
My .Net code (i.e service defination) is ---
[WebMethod]
public String ServiceName(string strParam1, string strParam2)
{
try
{
string Con = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
SqlConnection sn = new SqlConnection(Con);
if (sn.State == ConnectionState.Open)
sn.Close();
sn.Open();
SqlTransaction trans = sn.BeginTransaction();
try
{
***// Following statement inserting EMPTY value in to the database***
Generic.db.DepositTransaction_insert(strParam1, strParam2, "INSERT");
return "Record Save Successfully";
}
catch (Exception ex)
{
return ex.ToString();
}
}
catch (Exception ex)
{
return ex.ToString();
}
}
Hope you understand what I'm trying to say..! Please help.. Thank you..!
Finally I got the answer. It was just a spelling mistake. See first 4 lines of my android code as
public final String WSDL_TARGET_NAMESPACE = "http://www.example.com/abc/";
public final String SOAP_ADDRESS = "http://www.example.com/abc/WS.asmx";
public final String TEST_OPERATION="ServiceName";
public final String TEST_SOAP_ACTION="http://www.example.com/abc/ServiceName";
it contains string as www.example.com it should be www.Example.com (It is Case sensitive)