作为回报SOAP XML - 机器人 [英] SOAP xml in return - Android

查看:132
本文介绍了作为回报SOAP XML - 机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用k2SOAP为Android时WebServices的处理。

I'm using k2SOAP for Android when dealing with webservices.

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("ProjectID", 1);

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

HttpTransportSE httpTransport = new HttpTransportSE(URL);

try {

    httpTransport.call(SOAP_ACTION, soapEnvelope);
    SoapObject result = (SoapObject) soapEnvelope.getResponse();
    String resultString = result.toString();
}

我知道有没有错code,因为它的工作原理与W3 Web服务。但W3C返回一个字符串作为回答这个Web服务返回的XML。我回来的答案是这样的,当我表现出来的日志:

I know there is nothing wrong with the code since it works with the w3 web service. But w3c returns a string as an answer this web service returns an XML. The answer I get back looks like this when I show it in log:

anyType{schema=anyType{element=anyType{complexType=anyType{choice=anyType{element=an    yType{complexType=anyType{sequence=anyType{element=anyType{}; 
element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; element=anyType{}; }; }; }; }; }; 
unique=anyType{selector=anyType{}; field=anyType{}; }; }; }; diffgram=anyType{}; }

这基本上是一个很大的噪音,我不知道如何从这个还是我应该如何分析它,或者得到的信息。我的最终目标是把我弄的到本地数据库,但该信息,因为我不知道如何从字符串的信息,我不知道放在数据库中的信息。

Which basically is a lot of noise and I'm not sure on how to get the information from this or how I should parse it or. My ultimate goal is to put the information I get in to a local database but since I don't know how to get the information from the String I don't know put the info in the database.

所以,我想要做的就是以某种方式解析信息,并把它放在我已经建立了类的本地数据库。 我如何从SoapObject结果的数据? 有一种轻微的可能性,Web服务信息是空的,但我的问题仍然是相同的。

So what I want to do is to somehow parse the information and put it in a local database which I already built the classes for. How do I get the data from the SoapObject result? There is a slight possibility the web service info is empty, but my question is still the same.

推荐答案

两件事情你需要修改

1)添加此httpTransport.setXmlVersionTag(< XML版本= \1.0 \编码= \UTF-8 \>);

上面一行httpTransport.call(SOAP_ACTION,的SoapEnvelope);

2)字符串resultString = result.toString();

替换上述符合以下任一

字符串resultString = httpTransport.responseDump;

这将返回响应,XML格式化字符串

This will return response as xml formated String

这篇关于作为回报SOAP XML - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆