Android代码:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo propInfo = new PropertyInfo();
propInfo.type = PropertyInfo.STRING_CLASS;
// adding parameters
request.addProperty("userID", "18");
//request.addProperty("password", "iprint");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
Log.e("Object response", "Before response ");
resultsRequestSOAP = (SoapObject) envelope.bodyIn;
//SoapObject response = (SoapObject) envelope.getResponse();
SoapObject returnObj = (SoapObject)resultsRequestSOAP.getProperty("return");
//Integer id = Integer.valueOf(returnObj.getProperty("id");
//String username = (String)returnObj.getProperty("value");
Log.v("key", returnObj.getProperty(2).toString());
//log.v("values", username);
Log.e("Object response",""+resultsRequestSOAP);
} catch (Exception e) {
e.printStackTrace();
Log.v("error", e.toString());
}
现在我明白了:
getProfileResponse{
return=Map{
item=anyType{key=firstName; value=Donette; };
item=anyType{key=lastName; value=Foller; };
item=anyType{key=company; value=; };
item=anyType{key=address1; value=34 Center St; };
item=anyType{key=address2; value=; };
item=anyType{key=city; value=Hamilton; };
item=anyType{key=state; value=41; };
item=anyType{key=postcode; value=45011; };
item=anyType{key=country; value=1; };
item=anyType{key=telephone; value=513-570-1893; };
item=anyType{key=mobile; value=513-549-4561; };
item=anyType{key=fax; value=513-570-1893; };
};
}
但我需要这样的输出: -
firstName,Donette lastName,Foller .. .. .. fax,513-570-1893;
答案 0 :(得分:0)
SoapObject returnObj = (SoapObject)resultsRequestSOAP.getProperty("return");
SoapObject finalReturn;
for(int i=0;i<returnObj.getPropertyCount();i++){
finalReturn= (SoapObject) returnObj.getProperty(i);
Log.v("key", finalReturn.getProperty(0).toString()+" "+finalReturn.getProperty(1).toString());
}