-1
這是我的web服務代碼。我不知道如何解析soap響應,我該怎麼做?我甚至不知道它是json還是Xml.So請告訴我它是哪種類型的響應? 我的回答是這樣如何解析來自asp.net的soapobject響應
anyType的{Product_Details = {anyType的P_ID = 129; p_name = FFFF; C_name = GGGG;};}
public class MyAsyncTask extends AsyncTask<String, String , String>
{
@Override
protected void onPostExecute(String arrPersons)
{
uid.setText(arrPersons);
}
@Override
protected void onProgressUpdate(String... text)
{
uid.setText(text[0]);
}
@Override
protected String doInBackground(String... arg0)
{
SOAP_ADDRESS="";
request=new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);
publishProgress("Loading contents...");
PropertyInfo pi=new PropertyInfo();
pi.setName("PID");
pi.setValue(Integer.parseInt(arg0[1]));
pi.setType(String.class);
request.addProperty(pi);
pi=new PropertyInfo();
envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
httpTransport=new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
SoapObject response = (SoapObject)envelope.getResponse();
for (int i = 0; i < response.getPropertyCount(); i++)
{
Object property = response.getProperty(i);
if (property instanceof SoapObject)
{
SoapObject category_list = (SoapObject) property;
String returnString1 = category_list.getProperty(0).toString();
}
}
}
catch (Exception e)
{
returnString1 = e.getMessage();
}
return returnString1;
}
}