2

I have to develop an application which includes following things,

=> Make a request to the Web Service through an iPhone...

=> fetch Data from web service...

I have never used an web service to develop iPhone application.

But i know what is web service.

The example of web service is given below. a snapshot alt text

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
sagarkothari
  • 24,520
  • 50
  • 165
  • 235

3 Answers3

5

To retrieve data from the webservice you can use NSURLRequest or NSMutableURLRequest

...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.

JeroenEijkhof
  • 2,232
  • 2
  • 25
  • 39
Daniel
  • 22,363
  • 9
  • 64
  • 71
  • I would also recommend Apple's "URL Loading System Programming Guide: Introduction" (http://bit.ly/jjAC4Y). The guide of how to use the above mentioned links. – JeroenEijkhof May 10 '11 at 05:03
1

I developed some REST services using ASP.NET MVC to return XML documents that were created using Apple's native plist schema. The iphone can very naturally parse plists into their native types. plist is a little verbose compared to JSON, but I don't think it's that much more payload overhead.

If you already have some SOAP web services, then you will have to build your own custom, domain-specific XML parser.

-MrB

Matthew Belk
  • 1,904
  • 2
  • 20
  • 28
0

U can do it this way...

-(NSString* )createWebServiveRequest:(NSString *)urlLink{

NSURL *url = [NSURL URLWithString:urlLink];

NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60];

NSData *returnData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse: nil error: nil ];

NSString *responseString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

return responseString; }

call the above method with the nsstring containing url.....and capture it in the method call.

Granit
  • 1,261
  • 6
  • 19
  • 35
Pradeep Reddy Kypa
  • 3,992
  • 7
  • 57
  • 75