Wednesday, September 15, 2010

Processing Xml Webservices in IPhone

In this 2 part series I will show you how we can communicate to .NET XML web service(SOAP and REST types) using XCode. The detailed document is available for download HERE

Today I will discuss how to communicate to a SOAP based web service in your IPhone applications.We should keep in mind the fact that unlike .Net or Java where consuming web service is just a matter of a few clicks and the IDE's do the work of creating the proxy code for you,in XCode we have to manually do the web service configuration,making http/https calls and parsing the resulting Xml.

I would not be teach you creating .Net web services here but in my example I have a web service method named getPointsHistoryByCustomerID which takes an input value of a customer id,queries the database layer and returns the associated Customer profile as XML.

Refer to the PDF Document for details of the whole process along with the configuring/coding NSURL and NSURLConnection objects and using the delegates which are essential for request/response processing :

- (void)connection:(NSURLConnection *)connection didReceiveResponse:
(NSURLResponse *)response

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

-(void) connectionDidFinishLoading:(NSURLConnection *) connection

-(void) connection:(NSURLConnection *) connection didFailWithError:(NSError *) error

No comments:

Post a Comment