如何使用KSOAP2使用更复杂的SOAP服务?

时间:2019-02-22 15:46:06

标签: java android web-services soap ksoap2

在我的问题ClassCastException (Vector > SoapPrimative)之后,有人可以提供如何使用以下WebService响应的示例吗,我一直在使用以下代码(来自Internet上的许多示例),但无法获取除了最简单的响应(例如w3schools Temperature Convert)之外,还可以使用其他任何方法

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.implicitTypes = true;
envelope.setOutputSoapObject(request);

HttpTransportSE httpTransportSE = new HttpTransportSE(URL);

httpTransportSE.call(NAMESPACE + methodName, envelope);
SoapPrimitive soapPrimitive = (SoapPrimitive) envelope.getResponse();

我的回复的简化版本:

<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>
    <TestResponse xmlns="http://tempuri.org/">
       <TestResult>
          <CodeCheck>1234</CodeCheck>
          <AccountBalance>101.25</AccountBalance>
          <Company>BBC</Company>
          <Books>
             <Book>
                <Title>Book Title 1</Title>
                <Author>Mr A Smith</Author>
             </Book>
             <Book>
                <Title>Book Title 2</Title>
                <Author>Mr B Jones</Author>
             </Book>
          </Books>
       </TestResult>
    </TestResponse>
  </soap:Body>
</soap:Envelope>

0 个答案:

没有答案