消耗.NET的WebService - 针对Android的ASMX WebService的解析数据数组 [英] Consume .NET WebService - Parsing an array of data from an asmx WebService in Android
问题描述
我有一个.NET的Web服务与ASMX扩展。
该服务 http://www.web.com/SampleService/SampleService.asmx 有两个终点:
首先是 http://www.web.com/SampleService/SampleService.asmx/的GetName
它提供了以下格式的用户名:
类似地,第二端点 http://www.web.com/SampleService/SampleService的.asmx / GetTax 也返回一些XML数据。
我想从链接 HTTP解析这两个XML数据://www.web。 COM / SampleService / SampleService.asmx
我读<一个href=\"http://translate.google.com.ua/translate?hl=uk&sl=ru&tl=en&u=http://mobile-developer.ru/uncategorized/rabota-s-soap-web-servisami-v-android-prilozheniyax/\"相对=nofollow>其中描述了如何使用 kSOAP2消耗在Android Web服务的应用,这教程 - 库
。但是,在本教程中,他们解释如何将数据传递到网络,并提出一些添加操作。但我需要解析从ASMX链接上面给出的XML数据,并更新结果为的ListView
。我怎样才能做到这一点?请人帮我一个完整的例子?
私有静态无效parseResponse(InputStream为,信封的SoapEnvelope)
抛出的Throwable
尝试{
XmlPullParser XP =新KXmlParser();
xp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,真); xp.setInput(是,UTF-8); // UTF-8 envelope.parse(XP);
}赶上(Throwable的E){
Log.e(LOG_TAG,错误读取/解析SOAP响应,E);
Ë扔掉;
}
}
...
parseResponse(是,信封);
对象bodyIn = envelope.bodyIn;
如果(bodyIn的instanceof的SOAPFault){
抛出(的SOAPFault)bodyIn;
}
其中,是
是您的网络请求的输入流。如果解析正常,该bodyIn将包含 SoapObject
I have a .NET Web-services with asmx extension. The service http://www.web.com/SampleService/SampleService.asmx has two endpoints:
First is http://www.web.com/SampleService/SampleService.asmx/GetName which provides the name of the customers in the following format:
Similarly, the second endpoint http://www.web.com/SampleService/SampleService.asmx/GetTax also returns some XML data.
I want to parse both of those xml data from the link http://www.web.com/SampleService/SampleService.asmx
I have read this tutorial which describes how to consume Web-services applications in the Android by using kSOAP2 - library
. But in this tutorial, they explained how to pass the data to web and make some adding operation. But I need to parse the xml data from asmx link given above, and update the results to a ListView
. How can I do this? Please anyone help me with a full example?
private static void parseResponse(InputStream is, SoapEnvelope envelope)
throws Throwable {
try {
XmlPullParser xp = new KXmlParser();
xp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
xp.setInput(is, "UTF-8"); //UTF-8
envelope.parse(xp);
} catch (Throwable e) {
Log.e(LOG_TAG, "Error reading/parsing SOAP response", e);
throw e;
}
}
....
parseResponse(is, envelope);
Object bodyIn = envelope.bodyIn;
if (bodyIn instanceof SoapFault) {
throw (SoapFault) bodyIn;
}
where is
is the input stream from your web request. If parsing is ok, the bodyIn will contain SoapObject
这篇关于消耗.NET的WebService - 针对Android的ASMX WebService的解析数据数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!