Android如何解析和使用Web服务?

时间:2014-11-26 13:42:33

标签: android web-services soap xml-parsing android-ksoap2

我如何在android中解析这种类型的web服务?请看下面的图片。我在.net中创建了这个web服务,现在我想解析并使用Android中的Login webservice。请任何人帮助它将非常感激。感谢

SOAP 1.1

 The following is a sample SOAP 1.1 request and response. The placeholders shown need to be  replaced with actual values.

POST /Service.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/Login"

<?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>
 <Login xmlns="http://tempuri.org/">
  <username>string</username>
  <password>string</password>
  <apptypecode>string</apptypecode>
  </Login>
 </soap:Body>
</soap:Envelope>

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

 <?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>
 <LoginResponse xmlns="http://tempuri.org/">
  <LoginResult>string</LoginResult>
 </LoginResponse>
 </soap:Body>
 </soap:Envelope>