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
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.
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:
http://www.slideshare.net/akosma/web-services-3439269
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];
In my opinion, you have two options :