SlideShare a Scribd company logo
1 of 24
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.
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
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;
}
That’s all for today

More Related Content

What's hot

Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node jsHabilelabs
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBJustin Smestad
 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorialsMongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorialsSpringPeople
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDBMongoDB
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & IntroductionJerwin Roy
 
Introduction to couchdb
Introduction to couchdbIntroduction to couchdb
Introduction to couchdbiammutex
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialPHP Support
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverMongoDB
 

What's hot (20)

Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
Node js crash course session 2
Node js crash course   session 2Node js crash course   session 2
Node js crash course session 2
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Mongo db basics
Mongo db basicsMongo db basics
Mongo db basics
 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorialsMongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
 
Xml processors
Xml processorsXml processors
Xml processors
 
MongoDB
MongoDBMongoDB
MongoDB
 
Introduction to JSON & AJAX
Introduction to JSON & AJAXIntroduction to JSON & AJAX
Introduction to JSON & AJAX
 
Building Your First Application with MongoDB
Building Your First Application with MongoDBBuilding Your First Application with MongoDB
Building Your First Application with MongoDB
 
Json
Json Json
Json
 
Understanding XML DOM
Understanding XML DOMUnderstanding XML DOM
Understanding XML DOM
 
MongoDB basics & Introduction
MongoDB basics & IntroductionMongoDB basics & Introduction
MongoDB basics & Introduction
 
Dom parser
Dom parserDom parser
Dom parser
 
Mongo db
Mongo dbMongo db
Mongo db
 
Introduction to couchdb
Introduction to couchdbIntroduction to couchdb
Introduction to couchdb
 
Elastic Search
Elastic SearchElastic Search
Elastic Search
 
Ajax xml json
Ajax xml jsonAjax xml json
Ajax xml json
 
Node Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js TutorialNode Js, AngularJs and Express Js Tutorial
Node Js, AngularJs and Express Js Tutorial
 
Webinar: What's new in the .NET Driver
Webinar: What's new in the .NET DriverWebinar: What's new in the .NET Driver
Webinar: What's new in the .NET Driver
 
Mongo DB 102
Mongo DB 102Mongo DB 102
Mongo DB 102
 

Similar to Using Webservice in iOS

Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorialprathap kumar
 
Windows communication foundation (part1) jaliya udagedara
Windows communication foundation (part1)    jaliya udagedaraWindows communication foundation (part1)    jaliya udagedara
Windows communication foundation (part1) jaliya udagedaraJaliya Udagedara
 
SOAP Service in Mule Esb
SOAP Service in Mule EsbSOAP Service in Mule Esb
SOAP Service in Mule EsbAnand kalla
 
Dojo - from web page to web apps
Dojo - from web page to web appsDojo - from web page to web apps
Dojo - from web page to web appsyoavrubin
 
WebServices Basic Introduction
WebServices Basic IntroductionWebServices Basic Introduction
WebServices Basic IntroductionShahid Shaik
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government DevelopersFrank La Vigne
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONSyed Moosa Kaleem
 
Introduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshIntroduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshSiddhesh Bhobe
 
Introduction of WebServices
Introduction of WebServicesIntroduction of WebServices
Introduction of WebServicesKhasim Saheb
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 

Similar to Using Webservice in iOS (20)

Ntg web services
Ntg   web servicesNtg   web services
Ntg web services
 
Web Services
Web Services Web Services
Web Services
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
 
Web services for banks
Web services for banksWeb services for banks
Web services for banks
 
Windows communication foundation (part1) jaliya udagedara
Windows communication foundation (part1)    jaliya udagedaraWindows communication foundation (part1)    jaliya udagedara
Windows communication foundation (part1) jaliya udagedara
 
SOAP Service in Mule Esb
SOAP Service in Mule EsbSOAP Service in Mule Esb
SOAP Service in Mule Esb
 
Webservices
WebservicesWebservices
Webservices
 
Bespoke Digital Media - Web
Bespoke Digital Media - Web Bespoke Digital Media - Web
Bespoke Digital Media - Web
 
Dojo - from web page to web apps
Dojo - from web page to web appsDojo - from web page to web apps
Dojo - from web page to web apps
 
Web services
Web servicesWeb services
Web services
 
WebServices Basic Introduction
WebServices Basic IntroductionWebServices Basic Introduction
WebServices Basic Introduction
 
Web services overview
Web services overviewWeb services overview
Web services overview
 
Developmeant and deployment of webservice
Developmeant and deployment of webserviceDevelopmeant and deployment of webservice
Developmeant and deployment of webservice
 
Intro to .NET for Government Developers
Intro to .NET for Government DevelopersIntro to .NET for Government Developers
Intro to .NET for Government Developers
 
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSONAn introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
An introduction to DOM , JAVASCRIPT , JQUERY, AJAX and JSON
 
Introduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshIntroduction To Dot Net Siddhesh
Introduction To Dot Net Siddhesh
 
Web Service Basics and NWS Setup
Web Service  Basics and NWS SetupWeb Service  Basics and NWS Setup
Web Service Basics and NWS Setup
 
Introduction of WebServices
Introduction of WebServicesIntroduction of WebServices
Introduction of WebServices
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
WebServices
WebServicesWebServices
WebServices
 

Recently uploaded

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

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.
  • 4.
  • 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
  • 9.
  • 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; }
  • 23.