android SOAP parsing
This is my SOAP web service:
POST /thehlb/mobile/mobileservice.asmx HTTP/1.1
Host: projects.spinxweb.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/CheckLogin"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CheckLogin xmlns="http://tempuri.org/">
<UserName>string</UserName>
<Password>string</Password>
<PhoneType>string</PhoneType>
<MoblieUniqueNo>string</MoblieUniqueNo>
</CheckLogin>
</soap:Body>
</soap:Envelope>
And this is my code ..
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//CALL the web service method with the two parameters vname an开发者_StackOverflow中文版d nname
SoapObject request = new SoapObject(NAMESPACE, METHOS_NAME);
request.addProperty( "UserName","test@yahoo.com");
request.addProperty("Password", "123");
request.addProperty("PhoneType", "Android");
request.addProperty("MoblieUniqueNo", "123456");
SoapSerializationEnvelope envelop = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelop.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
androidHttpTransport.debug = true;
try
{
androidHttpTransport.call(SOAP_ACTION, envelop);
// Get the SAOP Envelope back and the extract the body
SoapObject resultsRequestSOAP = (SoapObject) envelop.getResponse();
System.out.println("Responce :"+resultsRequestSOAP.toString());
Vector vector = (Vector) resultsRequestSOAP.getProperty("CheckLogin");
//Count of the arrays beneath starting from 0
SoapObject test = (SoapObject) vector.get(0);
//Get the attributes in the array
String uName = (String) test.getProperty("UserName");
uName = uName + " " + (String)test.getProperty("Password");
System.out.println("uname "+uName);
//Just show it in a text area field called lblStatus
TextView tv = (TextView) findViewById(R.id.textview);
tv.setText(uName.toString());
System.out.println("user name :"+tv);
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Error :"+e);
}
} //end onCreate method
I got an error to parse it. Does anyone have a solution? Plz help me .
You could try to use soapui or some other tool to see if the services are working. Then if the services are working check and see if the soap envelope you put in this is the same as that's created by SoapUI (well apart for the tag name pre-fixes). If there are differences check up on that.
精彩评论