如何在SoapObject中转换字符串对象

时间:2013-12-12 10:03:03

标签: android

我有一个本地字符串,如下所示:

String parseStr = "<?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>"
        + "<authenticateUser xmlns=\"http://playinktennismasters.com/\">"
        + "<user>Android</user>" + "</authenticateUser>" + "</soap:Body>"
        + "</soap:Envelope>";

我想在SoapObject中转换它,然后想要解析它。

如果有人知道该怎么做,请回复。

先谢谢。

1 个答案:

答案 0 :(得分:1)

这似乎有效:

public SoapObject createSoapObjectFromSoapObjectString(String soapObjectString)
{
// Create a SoapSerializationEnvelope with some config
SoapSerializationEnvelope env = new SoapSerializationEnvelope(SoapEnvelope.VER11);
env.dotNet = true;

// Set your string as output
env.setOutputSoapObject(soapObjectString);

// Get response
SoapObject so = (SoapObject) env.getResponse();

return so;
}