Before explaining how to connect to a Web service using Cocoa, you have to understand what is Web Service.
A Web Service is a site that contains methods and functions that can be consumed by other applications or websites. And whukeeping my methods and functions in the web service when I can have them in my application or website?
Sometimes you need to maintain the methods and functions outside of our application, when you need several applications or sites, re-use the same methods and web service functions, and not replicated for each application.
There are two types of web services
SOA. - Are the services that use a base architecture of communication messages.
ROA. - Are the services that use resources (resources) and communication based architecture, which is an implementation of REST, using technologies like XML, JSON, XHTML, plists.
Now going to the point in question, let's see how you can connect to a type of Web Service REST ...
For HTTP you can perform the following orders:
In this case we will make a GET request to the service, so we need to follow the following steps:
- Know the web service information such as your address URI, or the methods that we check, and their respective parameters
-Obtain and crumble the result
The result that we will get will be something like this:
- <date>Tues Jun 07 06 GMT 2011</date>
- <description>Example of response</description>
- <title>iPhone Example</title>
Since we know that we're going to find once you make the request to the web service, let's move to write code: