I want to know how can i use a String envelope in my Soap call method. Here is my envelope :
String soapEnvelope = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tem=\"http://tempuri.org\">\n"
+ "<soap:Header/>\n"
+ "<soap:Body>\n"
+ "<tem:GetItems>\n"
+ "<tem:catId>"+categoryId+"</tem:catId>\n"
+ "</tem:GetItems>\n"
+ "</soap:Body>\n"
+ "</soap:Envelope>\n";
I normally use
SoapObject request = new SoapObject(NAMESPACE, METHODNAME_MAINCATEGORIES);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransportSe = new HttpTransportSE(URL);
httpTransportSe.debug = true;
SoapObject response = null;
try{
httpTransportSe.call(SOAP_ACTION, envelope);
response = (SoapObject)envelope.getResponse();
SoapObject main = (SoapObject)response.getProperty(1);
SoapObject list = (SoapObject)main.getProperty(0);
//String a = Integer.toString(list.getPropertyCount());
//Log.i("property count", a);
for(int i = 0; i<list.getPropertyCount(); i++){
Categories c = new Categories();
SoapObject nsoap = (SoapObject)list.getProperty(i);
if(nsoap != null){
c.setId(nsoap.getProperty("Id").toString());
c.setMainId(nsoap.getProperty("MainID").toString());
c.setName(nsoap.getProperty("Name").toString());
}
}
}
catch(Exception e){
e.printStackTrace();
}
return categories;
kind of approach. But i need to add a parameter to this call, which is an integer value. I tried to add
request.addParameter("myValue", myValue);
where myValue is a parameter required to call this function. Here is portion of code:
public ArrayList<Item> getItems(int myValue){
SoapObject request = new SoapObject(NAMESPACE, METHODNAME_ITEMS);
request.addProperty("myValue", myValue);
Log.i("catId", String.valueOf(myValue));
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransportSe = new HttpTransportSE(URL);
httpTransportSe.debug = true;
SoapObject response = null;
I tried both String and int myValue params
, request always returns as "myValue" 0 (it returns items for 0 even if you enter 1,2,3,4 etc.). I made a research and learned that I need to create an envelope and give my parameter there. Now i created a String envelope that I gave above, how will i integrate it to my call ? Thanks for answers !