以编程方式完成时,SOAP的响应不正确

时间:2013-04-26 00:41:24

标签: android web-services soap

我的Android应用使用SOAP请求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.calottery.com/">
    <soapenv:Header/>
    <soapenv:Body>
    <ser:GetCurrentGameInfo/>
    </soapenv:Body>
    </soapenv:Envelope>


 When I test this using SOAPUI, I'm getting the Response(edited to minimum details) as ,

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <GetCurrentGameInfoResponse xmlns="http://services.calottery.com/">
         <GetCurrentGameInfoResult>
            <xs:schema id="CurrentGameInfo" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
               <xs:element name="CurrentGameInfo" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
               <xs:element name="QueryDate" type="xs:dateTime" minOccurs="0"/>
               </xs:element>                           
         </GetCurrentGameInfoResult>
      </GetCurrentGameInfoResponse>
   </soap:Body>
</soap:Envelope>

这是预期的结果。但是,当我从Android代码执行此操作时,如下所示,

SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
HttpTransportSE transport=new HttpTransportSE(URL);
try{
    transport.call(SOAP_ACTION, envelope);
        SoapObject result=(SoapObject)envelope.bodyIn;
        Log.v("Response", result.toString()); 
}
catch(Exception e){         e.printStackTrace();        }

我收到了回复

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; }; }; }; element=anyType{complexType=anyType{sequence=anyType{element=anyType{};

我在link中尝试了解决方案,但得到了同样的响应。我在这做错了什么?这是我正在使用的link to the service

1 个答案:

答案 0 :(得分:1)

我解决了这些问题。使用以下链接中给出的解决方案

Looper.prepare() ExceptionExtracting XML Data from SOAP。我在异步线程中有一个Toast消息,用于获取SOAP响应,当我删除它时,它一切正常