How to make a WSDL web service in iOS?

This post will describe about the basic web service on iOS applications.

Lets assume the following .wsdl url is the source URL. 

Create a SOAP Envelop and SOAP Header.

NSMutableString * soapHeader = @”<soapenv:Envelope xmlns:soapenv=\”\””

            ” xmlns:hom=\”“>”


Be remember that “xmlns:hom”, text next to “:” is the word which will be used as the targetnamespace reference for the service call which will be added in SOAP body.

SOAP body will be as follows :

[soapHeader appendString:@”<soapenv:Body>”];

[soapHeader appendString:@”<hom:GetGeoIP>”]; // add the body parameters

[soapHeader appendString:@”<hom:IPAddress></hom:IPAddress>”];

[soapHeader appendString:@”</hom:GetGeoIP>”];

[soapHeader appendString:@”</soapenv:Body>”];

[soapHeader appendString:@”</soapenv:envelope>”];

Now the web service is as follows:

NSMutableString * requestStr = [NSMutableStringstring];

[requestStr appendString:soapHeader];

NSString * urlStr = @”;;

    NSURL * url = [NSURL URLWithString:urlStr];

    NSMutableURLRequest * request = [[NSMutableURLRequestalloc] initWithURL:url];

    [request setValue:@”” forHTTPHeaderField:@”SOAPAction”];

    [request setValue:@”” forHTTPHeaderField:@”targetNamespace”];

    [request setValue:@”text/xml;charset=UTF-8″forHTTPHeaderField:@”Content-Type”];

    [request setHTTPBody:requestBody];

    [request setHTTPMethod:@”POST”];

    [request setValue:[NSStringstringWithFormat:@”%d”,[requestBody length]] forHTTPHeaderField:@”Content-Length”];

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {

        BOOL isSuccess = YES;

        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;

        NSLog(@”received data—%@”,response);

        if(connectionError != nil) {

            isSuccess = NO;

            NSLog(@”connection error with code %d”,connectionError.code);


        NSDictionary * responseDictionary = [NSDictionary dictionary];

        if([httpResponse statusCode] == 200) {

            isSuccess = YES;

         //Do something with the received dictionary.


This is the basic platform how we can make a simple SOAP based web service calls in iOS.

Happy coding !!!!