如何从Android中的.svc Web Service读取XML?

时间:2014-01-16 08:52:01

标签: android xml

我正在尝试从.SVC webservice读取XML我能够读取服务我的意思是我获取数据但数据不是XML格式。数据看起来像这样。

"\u003cPLAuthenticationWCF\u003e\u003cMobileAppKey /\u003e\u003cIsAuthenticated\u003e0\u003c/IsAuthenticated\u003e\u003cReason\u003eInvalid username or password.\u003c/Reason\u003e\u003c/PLAuthenticationWCF\u003e" 

现在如何在android中阅读这种XML请帮帮我。我经常搜索,但现在找到了任何有用的解决方案。我使用下面的代码从.SVC webserive获取数据。

String SOAP_ACTION = "http://tempuri.org/xxxxxx/" + method;
    String SOAP_METHOD = method;

    String soapMessage = "";
    try {
        SoapObject request = new SoapObject(NAMESPACE, SOAP_METHOD);
        request.addProperty("xxxxxxx", UserName);
        request.addProperty("xxxxx", Password);
        request.addProperty("Content-Type", "text/xml; charset=utf-8");
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;
        androidHttpTransport
                .setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
        androidHttpTransport.call(SOAP_ACTION, envelope);

        SoapPrimitive result = (SoapPrimitive) envelope.getResponse();

        /* Object */
        //result = (SoapPrimitive) envelope.getResponse();
        soapMessage = result.toString();
        readXML(soapMessage);
        return soapMessage;

    } catch (Exception e) {
        Logcat.e("UpdateProduct", "Error : " + e.toString());
        return soapMessage;
    }

0 个答案:

没有答案