SlideShare a Scribd company logo
Working with Web Service in iOS
Syed Mahboob Nur
iOS Developer
Blog: http://mahboobiosdeveloper.blogspot.com/
Fb Profile:
https://www.facebook.com/mahboob.nur
Meetnar Profile:
http://www.meetnar.com/Home/UserDetails/24
Web Service
A Web service is a method of communications
between two electronic devices over the World
Wide Web. It is a software function provided at
a network address over the web with the service
always on as in the concept of utility computing.
Using Webservice  in iOS
Several Types of Web Services
WSDL
• WSDL stands for Web Services Description
Language
• WSDL is an XML-based language for describing
Web services.
• WSDL is a W3C recommendation
Several Types of Web Services
SOAP
• SOAP stands for Simple Object Access Protocol
• SOAP is an XML based protocol for accessing
Web Services.
• SOAP is based on XML
• SOAP is a W3C recommendation
Several Types of Web Services
UDDI
• UDDI stands for Universal Description,
Discovery and Integration
• UDDI is a directory service where companies
can search for Web services.
• UDDI is described in WSDL
• UDDI communicates via SOAP
Several Types of Web Services
RDF
• RDF stands for Resource Description
Framework
• RDF is a framework for describing resources
on the web
• RDF is written in XML
• RDF is a W3C Recommendation
Using Webservice  in iOS
Advantage of Using Web Service in
Mobile Application
•
•
•
•

Minimize application size
Minimize Code Size
Easy to modify
Reuse Application
Disadvantage of Using Web Service in
Mobile Application

• Internet Connection Required
• Server have to be active 24/7
Working with Web Service in iOS
(WSDL)
WSDL is an XML format for describing network
services as a set of endpoints operating on
messages containing either document-oriented
or procedure-oriented information. The
operations and messages are described
abstractly, and then bound to a concrete
network protocol and message format to define
an endpoint. Related concrete endpoints are
combined into abstract endpoints (services)
WSDL Example
<xml>
<types> <schema targetNamespace="http://example.com/
stockquote.xsd" xmlns="http://www.w3.org/2000/10/
XMLSchema"> <element name="TradePriceRequest">
<complexType>
<all> <element name="tickerSymbol" type="string"/>
</all>
</complexType> </element> <element name="TradePrice">
<complexType>
<all> <element name="price" type="float"/>
</all>
</complexType> </element> </schema>
</types>
</xml>
Steps of Implementing XML Service in
IOS
• Create a XML Parser file as NSObject type.
• Write relevant code in the files.
• Call the XML Parser class in a View Controller
Class and load XML by url .
• Parse the data and load in the containers or
view components. Example : Table View,
Picker View, Labels, Text Field etc.
Create a XML Parser file as NSObject
type.
#import <Foundation/Foundation.h>
//#import "TeamViewController.h"
#import "TeamInfo.h"
@interface TeamParser : NSObject<NSXMLParserDelegate>
{
NSString *currentNodeImage;
NSString *currentNodeName;
NSXMLParser
*parser;
NSMutableArray *imageArray;
NSMutableArray *nameArray;
TeamInfo*teamInfo;
}
@property (nonatomic, retain) NSMutableArray *imageArray;
@property (nonatomic, retain) NSMutableArray *nameArray;

-(id) loadXMLByURL:(NSString *)urlString;
@end
.m file implementation
#import "TeamParser.h"
@implementation TeamParser
@synthesize imageArray;

-(id) loadXMLByURL:(NSString *)urlString
{
imageArray= [[NSMutableArray alloc] init];
nameArray=[[NSMutableArray alloc]init];
NSURL *url = [NSURL URLWithString:urlString];
//parser = [[NSXMLParser alloc] initWithData:aData];
parser= [[NSXMLParser alloc] initWithContentsOfURL:url];
//parser = [[NSXMLParser alloc] initWithData:aData];
parser.delegate=self;
[parser parse];
return self;
}
- (void) parser:(NSXMLParser *)parser didStartElement:(NSString
*)elementname namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName attributes:(NSDictionary
*)attributeDict
{
if ([elementname isEqualToString:@"team"])
{
currentNodeImage=[[NSString alloc] init] ;
currentNodeName=[[NSString alloc]init];
teamInfo=[[TeamInfo alloc]init];
}
}
- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementname isEqualToString:@"logo"]) {
teamInfo.teamLogo = currentNodeImage;
//NSLog(@"image:%@",currentNodeImage);
}
if ([elementname isEqualToString:@"name"]) {
teamInfo.teamName = currentNodeImage;
//NSLog(@"name:%@",currentNodeImage);
}
if ([elementname isEqualToString:@"team"])
{
[imageArray addObject:teamInfo];
[currentNodeImage release];
[currentNodeName release];
currentNodeImage = nil;
currentNodeName=Nil;
}
Call the XML Parser class in a View
Controller Class and load XML by url .
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
teamImageParser = [[TeamParser alloc]
loadXMLByURL:@"http://www.amarhost.info/sabbir/iOS/AsiaCup/Services/teamlog
o.xml"];
imageNameArray=teamImageParser.imageArray;
teamNameArray=teamImageParser.nameArray;
for(int i=0;i<[imageNameArray count];i++)
{
NSLog(@"%@",[imageNameArray objectAtIndex:i]);
}
for(int i=0;i<[teamNameArray count];i++)
{
NSLog(@"%@",[teamNameArray objectAtIndex:i]);
Plot Parsed Data in the TableView
- (NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{

return [[teamImageParser imageArray] count];
}
Plot Parsed Data in the TableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
static NSString *CellIdentifier = @"TeamCustomCell";
TeamCustomCell *cell = (TeamCustomCell*)[teamTableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLabelObject = [[NSBundle mainBundle]
loadNibNamed:@"TeamCustomCell" owner:self options:nil];
for (id currentObject in topLabelObject)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (TeamCustomCell*) currentObject;
break;
TeamInfo *teamInfo;
teamInfo = [[teamImageParser imageArray] objectAtIndex:indexPath.row];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.headerTextLabel.text=teamInfo.teamName;
NSLog(@"teamName: %@",teamInfo.teamName);

imageQueueTeamLogo = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH,
0ul);
dispatch_async(imageQueueTeamLogo, ^
{
UIImage *imageTVGuideLogo = [UIImage imageWithData:[NSData
dataWithContentsOfURL: [NSURL URLWithString:[teamInfo teamLogo]]]];
dispatch_async(dispatch_get_main_queue(), ^
{
cell.titleImageView.image = imageTVGuideLogo;
[cell setNeedsLayout];
});
});
return cell;
}
Using Webservice  in iOS
That’s all for today

More Related Content

PDF
Difference between xml and json
PPT
Connecting to a REST API in iOS
PDF
iOS: Web Services and XML parsing
PPT
Web Services with Objective-C
PDF
mobile in the cloud with diamonds. improved.
PDF
FITC presents: Mobile & offline data synchronization in Angular JS
PPTX
Mongo db
PPTX
Node js crash course session 5
Difference between xml and json
Connecting to a REST API in iOS
iOS: Web Services and XML parsing
Web Services with Objective-C
mobile in the cloud with diamonds. improved.
FITC presents: Mobile & offline data synchronization in Angular JS
Mongo db
Node js crash course session 5

What's hot (20)

PPTX
Top 10 frameworks of node js
PPTX
Node js crash course session 2
PDF
Introduction to MongoDB
PDF
Mongo db basics
PPTX
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
PPTX
Xml processors
PPTX
PPTX
Introduction to JSON & AJAX
PPTX
Building Your First Application with MongoDB
PPT
PPT
Understanding XML DOM
PPTX
MongoDB basics & Introduction
PPTX
Dom parser
PDF
Introduction to couchdb
PDF
Elastic Search
PPTX
Ajax xml json
PDF
Node Js, AngularJs and Express Js Tutorial
PPTX
Webinar: What's new in the .NET Driver
PPTX
Mongo DB 102
Top 10 frameworks of node js
Node js crash course session 2
Introduction to MongoDB
Mongo db basics
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Xml processors
Introduction to JSON & AJAX
Building Your First Application with MongoDB
Understanding XML DOM
MongoDB basics & Introduction
Dom parser
Introduction to couchdb
Elastic Search
Ajax xml json
Node Js, AngularJs and Express Js Tutorial
Webinar: What's new in the .NET Driver
Mongo DB 102
Ad

Similar to Using Webservice in iOS (20)

PPTX
Web services for banks
PPT
2310 b 13
PPTX
Web Services
PPTX
3 web services bb
KEY
Hdc09 I Phone Dev Connecting To Web
DOCX
Webservices
PDF
Introducing Sudz-C
PPTX
API-Testing-SOAPUI-1.pptx
PPTX
Web services wsdl
PPTX
Web services wsdl
PPTX
Web services wsdl
PPTX
PPTX
PPTX
Web services
PPTX
Windows communication foundation (part1) jaliya udagedara
PPT
Developmeant and deployment of webservice
DOCX
Rest vs soap
PPT
Web Service
PPT
webservicearchitecture-150614164814-lva1-app6892.ppt
PPT
Web service architecture
Web services for banks
2310 b 13
Web Services
3 web services bb
Hdc09 I Phone Dev Connecting To Web
Webservices
Introducing Sudz-C
API-Testing-SOAPUI-1.pptx
Web services wsdl
Web services wsdl
Web services wsdl
Web services
Windows communication foundation (part1) jaliya udagedara
Developmeant and deployment of webservice
Rest vs soap
Web Service
webservicearchitecture-150614164814-lva1-app6892.ppt
Web service architecture
Ad

Recently uploaded (20)

PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Big Data Technologies - Introduction.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Review of recent advances in non-invasive hemoglobin estimation
Diabetes mellitus diagnosis method based random forest with bat algorithm
The AUB Centre for AI in Media Proposal.docx
sap open course for s4hana steps from ECC to s4
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
A comparative analysis of optical character recognition models for extracting...
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx

Using Webservice in iOS

  • 1. Working with Web Service in iOS
  • 2. Syed Mahboob Nur iOS Developer Blog: http://mahboobiosdeveloper.blogspot.com/ Fb Profile: https://www.facebook.com/mahboob.nur Meetnar Profile: http://www.meetnar.com/Home/UserDetails/24
  • 3. Web Service A Web service is a method of communications between two electronic devices over the World Wide Web. It is a software function provided at a network address over the web with the service always on as in the concept of utility computing.
  • 5. Several Types of Web Services WSDL • WSDL stands for Web Services Description Language • WSDL is an XML-based language for describing Web services. • WSDL is a W3C recommendation
  • 6. Several Types of Web Services SOAP • SOAP stands for Simple Object Access Protocol • SOAP is an XML based protocol for accessing Web Services. • SOAP is based on XML • SOAP is a W3C recommendation
  • 7. Several Types of Web Services UDDI • UDDI stands for Universal Description, Discovery and Integration • UDDI is a directory service where companies can search for Web services. • UDDI is described in WSDL • UDDI communicates via SOAP
  • 8. Several Types of Web Services RDF • RDF stands for Resource Description Framework • RDF is a framework for describing resources on the web • RDF is written in XML • RDF is a W3C Recommendation
  • 10. Advantage of Using Web Service in Mobile Application • • • • Minimize application size Minimize Code Size Easy to modify Reuse Application
  • 11. Disadvantage of Using Web Service in Mobile Application • Internet Connection Required • Server have to be active 24/7
  • 12. Working with Web Service in iOS (WSDL) WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services)
  • 13. WSDL Example <xml> <types> <schema targetNamespace="http://example.com/ stockquote.xsd" xmlns="http://www.w3.org/2000/10/ XMLSchema"> <element name="TradePriceRequest"> <complexType> <all> <element name="tickerSymbol" type="string"/> </all> </complexType> </element> <element name="TradePrice"> <complexType> <all> <element name="price" type="float"/> </all> </complexType> </element> </schema> </types> </xml>
  • 14. Steps of Implementing XML Service in IOS • Create a XML Parser file as NSObject type. • Write relevant code in the files. • Call the XML Parser class in a View Controller Class and load XML by url . • Parse the data and load in the containers or view components. Example : Table View, Picker View, Labels, Text Field etc.
  • 15. Create a XML Parser file as NSObject type. #import <Foundation/Foundation.h> //#import "TeamViewController.h" #import "TeamInfo.h" @interface TeamParser : NSObject<NSXMLParserDelegate> { NSString *currentNodeImage; NSString *currentNodeName; NSXMLParser *parser; NSMutableArray *imageArray; NSMutableArray *nameArray; TeamInfo*teamInfo; } @property (nonatomic, retain) NSMutableArray *imageArray; @property (nonatomic, retain) NSMutableArray *nameArray; -(id) loadXMLByURL:(NSString *)urlString; @end
  • 16. .m file implementation #import "TeamParser.h" @implementation TeamParser @synthesize imageArray; -(id) loadXMLByURL:(NSString *)urlString { imageArray= [[NSMutableArray alloc] init]; nameArray=[[NSMutableArray alloc]init]; NSURL *url = [NSURL URLWithString:urlString]; //parser = [[NSXMLParser alloc] initWithData:aData]; parser= [[NSXMLParser alloc] initWithContentsOfURL:url]; //parser = [[NSXMLParser alloc] initWithData:aData]; parser.delegate=self; [parser parse]; return self; }
  • 17. - (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if ([elementname isEqualToString:@"team"]) { currentNodeImage=[[NSString alloc] init] ; currentNodeName=[[NSString alloc]init]; teamInfo=[[TeamInfo alloc]init]; } }
  • 18. - (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementname isEqualToString:@"logo"]) { teamInfo.teamLogo = currentNodeImage; //NSLog(@"image:%@",currentNodeImage); } if ([elementname isEqualToString:@"name"]) { teamInfo.teamName = currentNodeImage; //NSLog(@"name:%@",currentNodeImage); } if ([elementname isEqualToString:@"team"]) { [imageArray addObject:teamInfo]; [currentNodeImage release]; [currentNodeName release]; currentNodeImage = nil; currentNodeName=Nil; }
  • 19. Call the XML Parser class in a View Controller Class and load XML by url . -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:YES]; teamImageParser = [[TeamParser alloc] loadXMLByURL:@"http://www.amarhost.info/sabbir/iOS/AsiaCup/Services/teamlog o.xml"]; imageNameArray=teamImageParser.imageArray; teamNameArray=teamImageParser.nameArray; for(int i=0;i<[imageNameArray count];i++) { NSLog(@"%@",[imageNameArray objectAtIndex:i]); } for(int i=0;i<[teamNameArray count];i++) { NSLog(@"%@",[teamNameArray objectAtIndex:i]);
  • 20. Plot Parsed Data in the TableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[teamImageParser imageArray] count]; }
  • 21. Plot Parsed Data in the TableView - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TeamCustomCell"; TeamCustomCell *cell = (TeamCustomCell*)[teamTableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSArray *topLabelObject = [[NSBundle mainBundle] loadNibNamed:@"TeamCustomCell" owner:self options:nil]; for (id currentObject in topLabelObject) { if ([currentObject isKindOfClass:[UITableViewCell class]]) { cell = (TeamCustomCell*) currentObject; break;
  • 22. TeamInfo *teamInfo; teamInfo = [[teamImageParser imageArray] objectAtIndex:indexPath.row]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.headerTextLabel.text=teamInfo.teamName; NSLog(@"teamName: %@",teamInfo.teamName); imageQueueTeamLogo = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); dispatch_async(imageQueueTeamLogo, ^ { UIImage *imageTVGuideLogo = [UIImage imageWithData:[NSData dataWithContentsOfURL: [NSURL URLWithString:[teamInfo teamLogo]]]]; dispatch_async(dispatch_get_main_queue(), ^ { cell.titleImageView.image = imageTVGuideLogo; [cell setNeedsLayout]; }); }); return cell; }