如何在android中使用Ksoap调用Webservice?

如何在android中使用Ksoap调用Webservice?,android,web-services,ksoap,Android,Web Services,Ksoap,我对android中的调用服务ksoap有问题,因为api服务不包含注释属性,所以我不调用服务,请帮助我 这是api服务 /api.asmx HTTP/1.1 Host: xxxx Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/RegisterEx" <?xml version="1.0" encoding="utf-8"?> <soa

我对android中的调用服务ksoap有问题,因为api服务不包含注释属性,所以我不调用服务,请帮助我

这是api服务

 /api.asmx HTTP/1.1
Host: xxxx
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/RegisterEx"

<?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>
    <RegisterEx xmlns="http://tempuri.org/">
      <objCustReg>
        <CustomerID>int</CustomerID>
        <Firstname>string</Firstname>
        <Lastname>string</Lastname>
        <Email>string</Email>
        <Passwd>string</Passwd>
        <Phone>string</Phone>
        <Address>string</Address>
        <City>string</City>
        <State>string</State>
        <Zipcode>string</Zipcode>
        <Country>string</Country>
        <RegisterDate>string</RegisterDate>
        <RegisteryBy>string</RegisteryBy>
        <Credit />
      </objCustReg>
      <Username>string</Username>
      <Passwd>string</Passwd>
    </RegisterEx>
  </soap:Body>
</soap:Envelope>

我的代码调用服务返回空,请帮助我。谢谢你

您必须尝试添加

envelope.implicitTypes=true;
,因为当前objCustReg的类型为RegisterEx。 改变

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);

因为你信封里的xsi和xsd是2001年的

您确定它不会打印异常堆栈跟踪吗

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);