如何从iPhone中的WebService获取数据? [英] How to Fetch Data From a WebService in iPhone?
问题描述
我必须开发一个包含以下内容的应用程序,
I have to develop an application which includes following things,
=>通过iPhone向Web服务发出请求...
=> Make a request to the Web Service through an iPhone...
=>从网络服务获取数据...
=> fetch Data from web service...
我从未使用过网络服务来开发iPhone应用程序。
I have never used an web service to develop iPhone application.
但我知道什么是网络服务。
But i know what is web service.
下面给出了网络服务的例子。快照
alt text http://www.freeimagehosting.net/uploads/af56220114。 png
The example of web service is given below. a snapshot alt text http://www.freeimagehosting.net/uploads/af56220114.png
推荐答案
要从网络服务中检索数据,您可以使用 NSURLRequest
或 NSMutableURLRequest
To retrieve data from the webservice you can use NSURLRequest
or NSMutableURLRequest
- Here is a reference
- Along with NSURLConnection
...您可以使用 + sendSynchronousRequest:re等方法turningResponse:错误:
或 sendAsynchronousRequest
。如果你只是在做一个get,你可以使用 [NSString s tringWithContentOfURL:url]
以非常简单的方式检索你的xml或者json这将在响应中读入字符串你把它分配给。
...where you can use methods such as + sendSynchronousRequest:returningResponse:error:
or sendAsynchronousRequest
. If you are simply doing a get, you can retrieve your xml or json in a very easy way using [NSString s tringWithContentOfURL:url]
this will read in the response into the string you assign it to.
这篇关于如何从iPhone中的WebService获取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!