Maybe it's because I'm not to android development - but I don't understand the difference between the two ways that I add parameters.
Is String[] not a String?
For example if i run my void onclick below. The webservice works as intended
public void onClick(View v) {
new Thread() {
@Override
public void run() {//Create request
try {
//start SoapObject
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
/*List<String> ArgumentPipeValue = new ArrayList<String>();
ArgumentPipeValue.add("_caseId|apples");
for (String arg : ArgumentPipeValue) {
String[] splitArgs = arg.split("|");
request.addProperty(splitArgs[0],splitArgs[1]);;
}*/
request.addProperty("_caseId", "apples");
//create the envelope
SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);
//Needed to make the internet call
HttpTransportSE androidHttpTransport = getHttpTransportSE();
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
//SoapObject soapResponse = (SoapObject) envelope.getResponse();
SoapPrimitive results = (SoapPrimitive)envelope.getResponse();
} catch (Exception e) {
e.printStackTrace();
Log.w("myApp", e.getMessage());
Log.w("myApp", e.getCause());
}
}
}.start();
}
However if I run the webservice the way below I get the error Unexpected token (position:TEXT Bad Request@1:12 in java.io.InputStreamReader@3709d6f6)
public void onClick(View v) {
new Thread() {
@Override
public void run() {//Create request
try {
//start SoapObject
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
List<String> ArgumentPipeValue = new ArrayList<String>();
ArgumentPipeValue.add("_caseId|apples");
for (String arg : ArgumentPipeValue) {
String[] splitArgs = arg.split("|");
request.addProperty(splitArgs[0],splitArgs[1]);
}
//request.addProperty("_caseId", "apples");
//create the envelope
SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);
//Needed to make the internet call
HttpTransportSE androidHttpTransport = getHttpTransportSE();
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
//SoapObject soapResponse = (SoapObject) envelope.getResponse();
SoapPrimitive results = (SoapPrimitive)envelope.getResponse();
} catch (Exception e) {
e.printStackTrace();
Log.w("myApp", e.getMessage());
Log.w("myApp", e.getCause());
}
}
}.start();
}
The only difference is I'm adding the property via request.addProperty("_caseId", "apples");
instead of request.addProperty(splitArgs[0],splitArgs[1]);
What am I missing? why does this happen?