Tuesday 21 June 2011

Soap webservice integration with iOS using ASIHTTP

Steps to implement

1) Send request to your web server
ASIHTTPRequest * request=[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://your web service url"]];

2) Create soap message body
NSString *soapMessage = [NSString stringWithFormat:@""
@""
@""
@"Your web service method"
@"
"
@"
"];

3) Add header to request
[request addRequestHeader:@"SOAPAction" value:@"http://temp_url/your_webservice_method"];

4) Append data with encoding
[request appendPostData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

5) Set request method
[request setRequestMethod:@"POST"];

6) Set content type to xml
[request addRequestHeader:@"Content-Type" value:@"text/xml"];

7) Set Delegate
request.delegate=self;

8) Set finish selector
 [request setDidFinishSelector:@selector(queue_requestDidFinish:)];

No comments:

Post a Comment

iOS interview questions

What is the difference between underscore and self (i.e self . xx and _xx)  ? What is property? What is the difference between weak and ...