SOAP Web Service Implementation in iOS

Introduction to SOAP 1.2 –  With the introduction to SOAP 1.2 , W3C has fixed many of the perceived short comings of the technology and pushing this to new levels of both adoption and ease-of -use. It should also be noted that the acronym SOAP no longer stands for Simple Object Access Protocol as of the 1.2 specification from the W3C organisation. If we have the following features then SOAP is a great solution :

  1. Asynchronous processing and invocation – If your application needs a guaranteed level of reliability and security then SOAP 1.2 offers additional standards to ensure this type of operations.
  2. Formal contracts – If both sides (provider and consumer) have to agree on the exchange format then SOAP 1.2 gives the rigid specifications for the type of interaction.
  3. State based operation – If the application needs contextual information and conversational state management then SOAP 1.2 has the support for Security, Transaction, Coordination, etc.

SOAP Building Blocks – A SOAP message is an ordinary XML document containing the following elements :-                                                                                                                           Envelope – Identifies the XML document as a SOAP message.                                               Header – Contains header information.It’s optional to include in envelop.                               Body – Contains call and response information.It’s required to include in envelop.               Fault – Provides information about errors that occurred while processing the message.

WSDL (Web Services Description Language) – WSDL is a document written in XML. The document describes a Web service. It specifies the location of the service and the operations (or methods) the service exposes.

Tools to generate iOS code from WSDL For SOAP Requests                                                    In iOS platform there is requirement to get iOS (Objective C) code from WSDL  for which we required to implement SOAP web service.There are mainly five tools which are used for generating code from WSDL in iOS technology.

  • Wsdl2Code
  • Wsdl2objc
  • WSClient++
  • Sudzc
  • GSoap toolkit

1. Wsdl2Code – Wsdl2Code engine is best tool to convert WSDL to iOS code via submitting WSDL link on it’s home page .iPhone generated code works with Xpathquery , libxml library and NSdata+Base64 for byte array Support.

2. Wsdl2objc – Wsdl2objc is an offline tool to convert WSDL to ios code. As input it is taking url and path where code will save on disk. Easy to use and implement for developers.

3. WSClient++ –  WSClient++ is an offline tool for generating iOS code from WSDL. Generated code is Non-managed and hard to handle. Code is in Non – ARC format  so required to convert it in ARC compatible code.There is requirement to add NSWSDL.h and NSWSDL.m file as resource of parsing files in project. We can download this from .

4. Sudzc –  Sudzc is an online paid tool for generating iOS code from WSDL via going on this link

 5. GSoap toolkit – GSoap toolkit is an opensource tool to convert WSDl in c/c++ form which can be use in iOS project for implementation of Soap. Hard to use use because of platform dependencies and hard to manage the code when integrating with objective C.

Code Implementation in iOS – If WSDL requirement is not too large and as parameters, there are no objects to send over web service then for implementation in iOS we can implement like this :-

NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 
"<soap:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap=\"\">\n"
"<soap:Body>\n" "<Hello xmlns=\"\">\n" 
"</soap:Envelope>\n", nameInput.text];  // nameInput contains parameter value

NSURL *url = [NSURL URLWithString:@""];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

if( theConnection )
    webData = [[NSMutableData data] retain];

Differences between SOAP versions 

  • SOAP 1.1 is based on XML 1.0  and SOAP 1.2 is based on XML Information Set (XML Info-set).
  • In SOAP 1.2 , you can use the specification of a binding to an underlying protocol to determine which XML serialisation is used in the underlying protocol data units. The HTTP binding that is specified in SOAP 1.2 – Part 2 uses XML 1.0 as the serialisation of the SOAP message info-set.
  • The XML namespaces for the envelope and encoding schemas have changed for SOAP 1.2. These changes distinguish SOAP processors from SOAP 1.1 and SOAP 1.2 messages and supports changes in the SOAP schema, without affecting existing implementations.
  • SOAP 1.1 is a single document. The SOAP 1.2 specification is organised in the parts.

About Arpit kulshrestha

Arpit K Kulshrestha Graduated in Computer Science with HONORS Degree in 2012. He is on mission to develop or to be a part of great mobile application which can enhance user experience and able to explore the world. 6 + Years of Apple Mobile Application Development Experience with a strong focus on Building Enterprise, Social Networking Applications and working with Objective-C, Xcode, Storyboard & Instruments. Working knowledge of Core iOS frameworks and skilled in debugging. He has developed apps using SOAP, REST, JSON and XML based Web Services. He is interested to pursue a career in Mobile Applications Development field and he is certain that his skills and work experience prepared him well for such role.
 He has been a specialist in Multimedia & Networking based iOS applications in these years. Have a good in depth knowledge in Network Programming models like TCP/IP. Have done several rich multimedia (Videos & Images) processing & manipulating applications in the same. 
He is accustomed to successfully juggling multiple projects and have an excellent track record of forging strong relationships with client. He work equally well in team-oriented and self-directed environments and find the challenges of the start-up setting stimulating. Specialties:- Map kit , Core Location , UIKit , Core Data , SQLite , Google API's , Facebook API's ,Cocoa 2D, Core Motion, Event Kit.
This entry was posted in iOS Development and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s