Hi,
I know how to connect to web server using an iPhone but now I have to connect the iPhone to a web service. I don't know how to do it and there is no demo or class available online.
Does anyone have any ideas?
Thanks
Hi,
I know how to connect to web server using an iPhone but now I have to connect the iPhone to a web service. I don't know how to do it and there is no demo or class available online.
Does anyone have any ideas?
Thanks
In my opinion, you have two options :
You can use these 2 lines which return the response of your HTTP request. You don't need any configuration. This code is usefull if you try to access a PHP scritp for example. After you just have to parse your result.
NSURL *URL=[[NSURL alloc] initWithString:stringForURL];
NSString *results = [[NSString alloc] initWithContentsOfURL :URL];
You might find this tutorial, called Intro to SOAP Web Services useful. He shows how to package a request, send it to a web service, and read the response.
If you need some help with XML parsing, there is the TouchXML library which will give you a nice xml "document" to work with. Just be cautious of memory usage.
If you have to parse large XML message this tutorial about libxml and xmlreader in Cocoa will show you how to parse XML with the lower-level event-style parsers.
The link that amrox provide, SOAP Web Services, does answer all the stuff that you asked for.
You can try this I made up some classes you can just include in your project and then follow the examples, you can even download a .net dataset and query it if you are using .net as the web service provider. http://grabalife.com/2009/10/19/using-net-web-services-and-dataset-objects-in-your-iphone-app/
You probably went with one of the solutions above, but this example app from Apple is great. It demonstrates how to use NSXMLParser to parse XML data on an RSS feed. SiesmicXML Example
There is also a good example on devx which you can connect via http post and/or get
I've created an open source application for iPhone OS 3.0 that shows how to use REST & SOAP services in iPhone application, using XML (using 8 different iPhone libraries), SOAP, JSON (using SBJSON and TouchJSON), YAML, Protocol Buffers (Google serialization format) and even CSV from a PHP sample app (included in the project).
http://github.com/akosma/iPhoneWebServicesClient
The project is modular enough to support many other formats and libraries in the future.
The following presentation in SlideShare shows my findings in terms of performance, ease of implementation and payload characteristics:
After long search, I found WSClient++ thats only tool available to generate objective-c source code to connect soap web service.