0

我有一个返回数据表的 Web 服务函数。如果我执行该网络服务,我会得到这样的结果。

<DataTable xmlns="http://tempuri.org/">
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="FTP" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="FTP">
<xs:complexType>
<xs:sequence>
<xs:element name="Host" type="xs:string" minOccurs="0"/>
<xs:element name="UserName" type="xs:string" minOccurs="0"/>
<xs:element name="password" type="xs:string" minOccurs="0"/>
<xs:element name="port" type="xs:short" minOccurs="0"/>
<xs:element name="FolderPath" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<DocumentElement xmlns="">
<FTP diffgr:id="FTP1" msdata:rowOrder="0">
<Host>192.168.1.10</Host>
<UserName>hiren</UserName>
<password>soni</password>
<port>21</port>
<FolderPath>Images/</FolderPath>
</FTP>
<FTP diffgr:id="FTP2" msdata:rowOrder="1">
<Host>192.168.10.10</Host>
<UserName>hiren1</UserName>
<password>soni1</password>
<port>9021</port>
<FolderPath>Images/</FolderPath>
</FTP>
</DocumentElement>
</diffgr:diffgram>
</DataTable>

我已经使用 SOAP 在我的 android 应用程序中执行这个 web 服务。下面是我的eclipse代码。

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

        HttpTransportSE HttpTransport = new HttpTransportSE(SOAP_ADDRESS);
        Object response = null;

        try {
            HttpTransport.call(SOAP_ACTION, envelope);
            response = envelope.getResponse();
        } catch (IOException e) {
            response = e.toString();
        } catch (XmlPullParserException e) {
            response = e.toString();
        }

        return response.toString();
    }

现在我不知道如何读取我收到的这些数据。

顺便说一句,当我返回 response.toString() 时,它给了我这样的结果:

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=anyType{complexType=anyType{sequence=anyType{element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; }; }; }; }; }; }; }; diffgram=anyType{DocumentElement=anyType{FTP=anyType{Host=192.168.1.10; UserName=hiren; password=soni; port=21; FolderPath=Images/; }; FTP=anyType{Host=192.168.10.10; UserName=hiren1; password=soni1; port=9021; FolderPath=Images/; }; }; }; }
4

1 回答 1

0

我有同样的问题,以下几行解决了这个问题。试试以下几行,希望这会给你带有 XML 标签的数据,

httpTransport.debug=true; 
httpTransport.call(SOAP_ACTION, envelope);
String ss=httpTransport.responseDump; 
Log.d("Result --- ", ss);

这将打印 Web 服务返回的完整 xml 文件。

于 2012-09-19T10:12:51.147 回答