1
這是我的SOAP Web服務:Android的SOAP解析
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>
這是我的代碼..
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//CALL the web service method with the two parameters vname and nname
SoapObject request = new SoapObject(NAMESPACE, METHOS_NAME);
request.addProperty("UserName","[email protected]");
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
我得到一個錯誤解析它。有沒有人有辦法解決嗎? Plz幫助我。
什麼是錯誤? – Adinia 2011-03-14 13:38:45
什麼是錯誤? – longhairedsi 2011-03-14 13:41:17
SoapFault - faultcode:'System.Web.Services.Protocols.SoapException:服務器無法處理請求。 ---> System.NullReferenceException:未將對象引用設置爲對象的實例。 – dev 2011-03-14 13:50:17