SlideShare une entreprise Scribd logo
1  sur  32
DAY03
Web Services
INTERVIEW WITH A MOBILE DEVELOPER
Sara (MISS_ANDROID_94) is a Mobile Developer
She is a lovely person
She loves every one except the back end team
her company
They caused so many problems for her and
wasted her time and energy
Lets dig deeper in Sara’s problems
SOME OF SARA’S PROBLEMS
 Any changes in request / response structure done in the
back end breaks a feature in Sara’s app that takes time to
be working
 No consistency across the API in terms of data formats,
Json structure, status codes
 No navigation links are sent, so I have to
construct/concatenate all URIs of the API’s resources
 No proper documentation to use the API with examples
1- VERSIONING
API versioning is another feature we should
implement to achieve the robustness that is
especially important for mobile apps. Mobile
developers don't always have the luxury of
forcing software updates for all end users, so
our API is going to have to be able to handle
both old and new requests. We'll do this by
routing requests with a version number.
2- HYPERMEDIA
3- CONSISTENCY
Data Formats always JSON
JSON structure (single out put function
for all success and errors)
When dealing with dates and times,
remember that consistency is key.
4- DOCUMENTATION
DOCUMENTATION STEPS
Install npm with nodejs
Install APIDOC
Npm install apidoc –g
 Create a configuration file for apidoc
like this one
 Document your functions like this ->
 Run command
apidoc -i Model/ -o apidoc/
 Enjoy the help for your API
 Send it to the front end and
Mobile team or any team that
will consume your REST API
SOAP APIS
Part 4 (Last Part)
PHP AND XML
XML is another data formats to use
with API beside JSON
Human Readable
Easy to parse and Query
Better structural
WILL YOU CHOOSE JSON OR XML IN
THESE SITUATIONS AND WHY?
1. You are Designing a Backend in your company for a Mobile
and front end web team to have an interface to manage
some data (CRUD operations)
2. You are working in a tourism API for hotel availability (like
booking.com) and returning data about room types ,
availabilities, prices and amenities ( internet , breakfast,..etc)
this API will be consumed by many other websites .
3. You are making an API for prayer times per city that will be
consumed by many websites
CONVERT PHP ARRAY TO XML
Code Output
XML CLASSES IN PHP
AddChiled($key,$valu
e)
AddAttribute
($key,$value)
AsXML($filename)
PARSING XML TO PHP ARRAY
Code OutPut
PARSE RSS FEED
RSS Feed
 RSS Feed ( example) It is a way to easily distribute a
list of headlines, update notices, and sometimes content
to a wide number of people.
 The wonderful thing about RSS feeds is that they all
implement the same basic structure. Every feed
contains a wrapping "channel" tag. Then, each posting
in your feed will be wrapped within an "item" tag. All of
the information that we need can be accessed this way.
SOAP AND WSDL
SOAP
 A - WSDL is the standard format
for describing a web service.
 B - WSDL definition describes how
to access a web service and what
operations it will perform.
 C - WSDL is a language for
describing how to interface with
XML-based services
WSDL
 Simple Object access protocol
 RPC style services
 Uses WSDL
 Based on XML only
 One URL with methods as
parameters
 SOAP UI
COMPARISON SHEET
REST
 Mainly JSON based but can use XML and text
 Only HTTP
 One end point per resource (pretty URL)
 offer an effective way for interacting with
lightweight clients, such as smartphones.
 A REST client is more like a browser. It's a
generic client that knows how to use a
protocol and standardized methods,
 70% of public APIs are REST
SOAP
 XML based
 HTTP and other protocols (SMTP)
 WSDL
 One end point
 SOAP, the client needs previous knowledge on
everything it will be using, or it won't even
begin the interaction
SOAP
Simple Object Access
Protocol
Uses XML
WSDL Example :
http://api.radioreference.c
om/soap2/?wsdl&v=latest
SOAP IN PHP
Consuming a SOAP SERVICE
SOAPClient (?)
Think as PHP, what
should the constructor of
this class takes ?
Creating a SOAP Service
SOAPServer(?)
Think as PHP what else
is needed ?
CONSUMING A SOAP SERVICE
1. Make sure SOAP extension is installed in your PHP
 Phpinfo
 Extension_loaded
2. Create object from soapClient Class and pass the WSDL
file of your service to its constructor
3. Call any method of the WSDL
4. Enjoy
LET SEE WE WANT TO CALL THE GET
COUNTRIES LIST FUNCTION
SOAP UI
Can you test same service via just SOAP
UI ?
OUTPUT
CREATING A SOAP WEB SERVICE VIA
PHP STEP BY STEP
1. Prepare the class which includes your
methods (api documentation is a MUST)
2. Install PHP2WSDL tool via our sweet
composer
3. Generate the WSDL file for your service
4. Create the service
5. Test by SOAP UI
PREPARE THE CLASS
NO DOCUMENTATION = WSDL PROBLEMS
INSTALL PHP2WSDL
GENERATE WSDL
THE SERVICE
TEST THE SERVICE BY SOAP UI

Contenu connexe

Tendances

Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practicesAnkita Mahajan
 
Basic auth implementation using raml in mule
Basic auth implementation using raml in muleBasic auth implementation using raml in mule
Basic auth implementation using raml in muleAdithya Kuchan
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUDPrem Sanil
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaEdureka!
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsTessa Mero
 
05 Web Services
05 Web Services05 Web Services
05 Web Servicescrgwbr
 
The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTBruno Kessler Foundation
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web APIBrad Genereaux
 
REST-API's for architects and managers
REST-API's for architects and managersREST-API's for architects and managers
REST-API's for architects and managersPatrick Savalle
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 SlidesSuraj Gupta
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web ServicesAngelin R
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraintInviqa
 

Tendances (20)

Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
Http and REST APIs.
Http and REST APIs.Http and REST APIs.
Http and REST APIs.
 
Basic auth implementation using raml in mule
Basic auth implementation using raml in muleBasic auth implementation using raml in mule
Basic auth implementation using raml in mule
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
 
Consuming raml
Consuming ramlConsuming raml
Consuming raml
 
What is an API?
What is an API?What is an API?
What is an API?
 
Understanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple StepsUnderstanding REST APIs in 5 Simple Steps
Understanding REST APIs in 5 Simple Steps
 
Raml
RamlRaml
Raml
 
Play with force.com metadata
Play with force.com metadataPlay with force.com metadata
Play with force.com metadata
 
05 Web Services
05 Web Services05 Web Services
05 Web Services
 
The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReST
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
REST-API's for architects and managers
REST-API's for architects and managersREST-API's for architects and managers
REST-API's for architects and managers
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 Slides
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web Services
 
Rest API
Rest APIRest API
Rest API
 
REST, RESTful API
REST, RESTful APIREST, RESTful API
REST, RESTful API
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraint
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 

Similaire à Day03 api

Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Jackson F. de A. Mafra
 
Best practices and advantages of REST APIs
Best practices and advantages of REST APIsBest practices and advantages of REST APIs
Best practices and advantages of REST APIsAparna Sharma
 
Web services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigWeb services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigMandakini Kumari
 
What are restful web services?
What are restful web services?What are restful web services?
What are restful web services?Aparna Sharma
 
Ebook undisturbed rest-v1 [res_tful apis]
Ebook undisturbed rest-v1 [res_tful apis]Ebook undisturbed rest-v1 [res_tful apis]
Ebook undisturbed rest-v1 [res_tful apis]johnkbutcher
 
LAJUG Napster REST API
LAJUG Napster REST APILAJUG Napster REST API
LAJUG Napster REST APIstephenbhadran
 
Undisturbed rest chapter01
Undisturbed rest chapter01Undisturbed rest chapter01
Undisturbed rest chapter01Cuong Tran
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfAparna Sharma
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni InturiSreeni I
 
SOAP--Simple Object Access Protocol
SOAP--Simple Object Access ProtocolSOAP--Simple Object Access Protocol
SOAP--Simple Object Access ProtocolMasud Rahman
 
Java Web Service - Summer 2004
Java Web Service - Summer 2004Java Web Service - Summer 2004
Java Web Service - Summer 2004Danny Teng
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Charlin Agramonte
 
REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)Sascha Wenninger
 

Similaire à Day03 api (20)

Apitesting.pptx
Apitesting.pptxApitesting.pptx
Apitesting.pptx
 
Rest web service
Rest web serviceRest web service
Rest web service
 
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015
 
Best practices and advantages of REST APIs
Best practices and advantages of REST APIsBest practices and advantages of REST APIs
Best practices and advantages of REST APIs
 
Web services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigWeb services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGig
 
REST full API Design
REST full API DesignREST full API Design
REST full API Design
 
What are restful web services?
What are restful web services?What are restful web services?
What are restful web services?
 
Ebook undisturbed rest-v1 [res_tful apis]
Ebook undisturbed rest-v1 [res_tful apis]Ebook undisturbed rest-v1 [res_tful apis]
Ebook undisturbed rest-v1 [res_tful apis]
 
Salesforce Integration
Salesforce IntegrationSalesforce Integration
Salesforce Integration
 
LAJUG Napster REST API
LAJUG Napster REST APILAJUG Napster REST API
LAJUG Napster REST API
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
 
Undisturbed rest chapter01
Undisturbed rest chapter01Undisturbed rest chapter01
Undisturbed rest chapter01
 
Modern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdfModern REST API design principles and rules.pdf
Modern REST API design principles and rules.pdf
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
Web Programming
Web ProgrammingWeb Programming
Web Programming
 
SOAP--Simple Object Access Protocol
SOAP--Simple Object Access ProtocolSOAP--Simple Object Access Protocol
SOAP--Simple Object Access Protocol
 
Java Web Service - Summer 2004
Java Web Service - Summer 2004Java Web Service - Summer 2004
Java Web Service - Summer 2004
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5
 
soap toolkit
soap toolkitsoap toolkit
soap toolkit
 
REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)REST: So What's It All About? (SAP TechEd 2011, MOB107)
REST: So What's It All About? (SAP TechEd 2011, MOB107)
 

Plus de ABDEL RAHMAN KARIM

Plus de ABDEL RAHMAN KARIM (13)

Date Analysis .pdf
Date Analysis .pdfDate Analysis .pdf
Date Analysis .pdf
 
Agile Course
Agile CourseAgile Course
Agile Course
 
Agile course Part 1
Agile course Part 1Agile course Part 1
Agile course Part 1
 
Software as a service
Software as a serviceSoftware as a service
Software as a service
 
Search engine optimization
Search engine optimization Search engine optimization
Search engine optimization
 
Seo lec 3
Seo lec 3Seo lec 3
Seo lec 3
 
Seo lec 2
Seo lec 2Seo lec 2
Seo lec 2
 
Tdd for php
Tdd for phpTdd for php
Tdd for php
 
OverView to PMP
OverView to PMPOverView to PMP
OverView to PMP
 
Security fundamentals
Security fundamentals Security fundamentals
Security fundamentals
 
Software Design principales
Software Design principalesSoftware Design principales
Software Design principales
 
Over view of software artitecture
Over view of software artitectureOver view of software artitecture
Over view of software artitecture
 
تلخيص مختصر لكتاب التوحيد و التوكل للامام الغزالى من سلسلة احياء علوم الدين
تلخيص مختصر لكتاب التوحيد و التوكل للامام الغزالى من سلسلة احياء علوم الدينتلخيص مختصر لكتاب التوحيد و التوكل للامام الغزالى من سلسلة احياء علوم الدين
تلخيص مختصر لكتاب التوحيد و التوكل للامام الغزالى من سلسلة احياء علوم الدين
 

Dernier

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 

Dernier (20)

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 

Day03 api

  • 2. INTERVIEW WITH A MOBILE DEVELOPER Sara (MISS_ANDROID_94) is a Mobile Developer She is a lovely person She loves every one except the back end team her company They caused so many problems for her and wasted her time and energy Lets dig deeper in Sara’s problems
  • 3. SOME OF SARA’S PROBLEMS  Any changes in request / response structure done in the back end breaks a feature in Sara’s app that takes time to be working  No consistency across the API in terms of data formats, Json structure, status codes  No navigation links are sent, so I have to construct/concatenate all URIs of the API’s resources  No proper documentation to use the API with examples
  • 4. 1- VERSIONING API versioning is another feature we should implement to achieve the robustness that is especially important for mobile apps. Mobile developers don't always have the luxury of forcing software updates for all end users, so our API is going to have to be able to handle both old and new requests. We'll do this by routing requests with a version number.
  • 6.
  • 7. 3- CONSISTENCY Data Formats always JSON JSON structure (single out put function for all success and errors) When dealing with dates and times, remember that consistency is key.
  • 9. DOCUMENTATION STEPS Install npm with nodejs Install APIDOC Npm install apidoc –g
  • 10.  Create a configuration file for apidoc like this one  Document your functions like this ->
  • 11.  Run command apidoc -i Model/ -o apidoc/  Enjoy the help for your API  Send it to the front end and Mobile team or any team that will consume your REST API
  • 12. SOAP APIS Part 4 (Last Part)
  • 13. PHP AND XML XML is another data formats to use with API beside JSON Human Readable Easy to parse and Query Better structural
  • 14. WILL YOU CHOOSE JSON OR XML IN THESE SITUATIONS AND WHY? 1. You are Designing a Backend in your company for a Mobile and front end web team to have an interface to manage some data (CRUD operations) 2. You are working in a tourism API for hotel availability (like booking.com) and returning data about room types , availabilities, prices and amenities ( internet , breakfast,..etc) this API will be consumed by many other websites . 3. You are making an API for prayer times per city that will be consumed by many websites
  • 15. CONVERT PHP ARRAY TO XML Code Output
  • 16. XML CLASSES IN PHP AddChiled($key,$valu e) AddAttribute ($key,$value) AsXML($filename)
  • 17. PARSING XML TO PHP ARRAY Code OutPut
  • 18. PARSE RSS FEED RSS Feed  RSS Feed ( example) It is a way to easily distribute a list of headlines, update notices, and sometimes content to a wide number of people.  The wonderful thing about RSS feeds is that they all implement the same basic structure. Every feed contains a wrapping "channel" tag. Then, each posting in your feed will be wrapped within an "item" tag. All of the information that we need can be accessed this way.
  • 19. SOAP AND WSDL SOAP  A - WSDL is the standard format for describing a web service.  B - WSDL definition describes how to access a web service and what operations it will perform.  C - WSDL is a language for describing how to interface with XML-based services WSDL  Simple Object access protocol  RPC style services  Uses WSDL  Based on XML only  One URL with methods as parameters  SOAP UI
  • 20. COMPARISON SHEET REST  Mainly JSON based but can use XML and text  Only HTTP  One end point per resource (pretty URL)  offer an effective way for interacting with lightweight clients, such as smartphones.  A REST client is more like a browser. It's a generic client that knows how to use a protocol and standardized methods,  70% of public APIs are REST SOAP  XML based  HTTP and other protocols (SMTP)  WSDL  One end point  SOAP, the client needs previous knowledge on everything it will be using, or it won't even begin the interaction
  • 21. SOAP Simple Object Access Protocol Uses XML WSDL Example : http://api.radioreference.c om/soap2/?wsdl&v=latest
  • 22. SOAP IN PHP Consuming a SOAP SERVICE SOAPClient (?) Think as PHP, what should the constructor of this class takes ? Creating a SOAP Service SOAPServer(?) Think as PHP what else is needed ?
  • 23. CONSUMING A SOAP SERVICE 1. Make sure SOAP extension is installed in your PHP  Phpinfo  Extension_loaded 2. Create object from soapClient Class and pass the WSDL file of your service to its constructor 3. Call any method of the WSDL 4. Enjoy
  • 24. LET SEE WE WANT TO CALL THE GET COUNTRIES LIST FUNCTION
  • 25. SOAP UI Can you test same service via just SOAP UI ?
  • 27. CREATING A SOAP WEB SERVICE VIA PHP STEP BY STEP 1. Prepare the class which includes your methods (api documentation is a MUST) 2. Install PHP2WSDL tool via our sweet composer 3. Generate the WSDL file for your service 4. Create the service 5. Test by SOAP UI
  • 28. PREPARE THE CLASS NO DOCUMENTATION = WSDL PROBLEMS
  • 32. TEST THE SERVICE BY SOAP UI