PHP PDO & PHP SOAP Introduce. Agenda What is PHP PDO and PHP SOAP? Setup PHP PDO to connect database, query database and close the connection. Setup SOAP.

Slides:



Advertisements
Similar presentations
Intesar G Ali IT DepartmentPalestinian Land Authority Web services Prepared by: Intesar Ali IT Department PLA August 2010.
Advertisements

WEB SERVICES. FIRST AND FOREMOST - LINKS Tomcat AXIS2 -
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
Keys, Referential Integrity and PHP One to Many on the Web.
SOAP.
Web Services Web Services are the basic fundamental building blocks of invoking features that can be accessed by an application program. The accessibility.
Web Services Seminar: Service Description Languages
Web Services Darshan R. Kapadia Gregor von Laszewski 1http://grid.rit.edu.
G O B E Y O N D C O N V E N T I O N WORF: Developing DB2 UDB based Web Services on a Websphere Application Server Kris Van Thillo, ABIS Training & Consulting.
Understand Web Services
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
CSE 636 Data Integration Web Services.
Web service testing Group D5. What are Web Services? XML is the basis for Web services Web services are application components Web services communicate.
TP2653 Adv Web Programming SOAP and WSDL. SOAP Simple Object Access Protocol – Lightweight XML-based messaging protocol – A protocol for accessing a Web.
Introducing PHP Data Objects Wez Furlong
LIS651 lecture 7 PHP mySQL Thomas Krichel
INTERNET APPLICATION DEVELOPMENT For More visit:
PHP Data Object (PDO) Khaled Al-Sham’aa. What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform interface.
Sayed Ahmed Computer Engineering, BUET, Bangladesh MSC, Computer Science, U of Manitoba, Canada
Grid Computing, B. Wilkinson, 20043b.1 Web Services Part II.
WSDL: Web Services Definition Language CS 795/895.
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 19: Database Support.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Module 14: WCF Send Adapters. Overview Lesson 1: Introduction to WCF Send Adapters Lesson 2: Consuming a Web Service Lesson 3: Consuming Services from.
PHP With the New PDO::Informix Presented by: Thomas Beebe Advanced DataTools Corporation
Web Services & WCF ~ Ankit. Web services A web service is a collection of protocols and standards used for exchanging data between applications or systems.
PHP meets MySQL.
Tom Castiglia Hershey Technologies
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
PHP and MySQL CS How Web Site Architectures Work  User’s browser sends HTTP request.  The request may be a form where the action is to call PHP.
Lecture 10 – MYSQL and PHP (Part 2)
DAT 330 Building Web Services with SQL Server and SQLXML 3.0 Alexander Vaschillo Lead Program Manager WebData XML Group Microsoft Corporation.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
1 Web Service Description Language (WSDL) 大葉大學資工系.
CS 174: Web Programming September 2 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Chapter 10 Intro to SOAP and WSDL. Objectives By study in the chapter, you will be able to: Describe what is SOAP Exam the rules for creating a SOAP document.
Introduction to Web Services Instructor: Dr. M. Anwar Hossain.
3-Tier Client/Server Internet Example. TIER 1 - User interface and navigation Labeled Tier 1 in the following graphic, this layer comprises the entire.
Establishing a foundation for web services Ashraf Memon.
1 Web Services Web and Database Management System.
PHP Workshop ‹#› PHP Data Object (PDO). PHP Workshop ‹#› What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Formal Specification Of Web Services For Dependable Systems contribution to the PISA Workshop (25. – ) on the IP DeSIRE and the NoE DeFINE.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Intro to Web Services Dr. John P. Abraham UTPA. What are Web Services? Applications execute across multiple computers on a network.  The machine on which.
Introduction to Web Services Presented by Sarath Chandra Dorbala.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Web Service Definition Language. Web Services: WSDL2 Web Service Definition Language ( WSDL ) What is a web service? [ F. Leymann 2003 ] A piece of code.
Copyright 2007, Information Builders. Slide 1 iWay Web Services and WebFOCUS Consumption Michael Florkowski Information Builders.
Web Services Blake Schernekau March 27 th, Learning Objectives Understand Web Services Understand Web Services Figure out SOAP and what it is used.
PDOStatement Named Placeholders CIT336 - Connor Wiseman cit336.saveandquit.net/presentation.
SOAP, Web Service, WSDL Week 14 Web site:
XML 1. Chapter 8 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SAMPLE XML SCHEMA (XSD) 2 Schema is a record definition, analogous to the.
Web Services Dr.Kwanchai Eurviriyanukul The contents of this slide set are obtained from various sources including W3School, WIKIPEDIA.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 9 Web Services: JAX-RPC,
Web Database Programming Using PHP
PHP Data Objects for MySQL
WEB SERVICES.
Writing simple Java Web Services using Eclipse
Web Database Programming Using PHP
Unit – 5 JAVA Web Services
Implementing a service-oriented architecture using SOAP
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Web services, WSDL, SOAP and UDDI
MySQL Web Application Connecting to a MySQL database
Presentation transcript:

PHP PDO & PHP SOAP Introduce

Agenda What is PHP PDO and PHP SOAP? Setup PHP PDO to connect database, query database and close the connection. Setup SOAP Server and SOAP Client.

What is PHP PDO? PDO (PHP Data Objects) is an interface for accessing databases in PHP To use a database we need to do 3 things: – Connect to the database – Query the database using SQL – Do something with result – Close the connection to the database In this slide, we use MySQL for demo. With another Database please see details in here.here

Connect to the database (1) See the figure below to know how PDO work with database

Connect to the database (2) Connect to MySQL database: – And we should always wrap your PDO operations in a try/catch as PDO uses exceptions to trap errors (there 3 modes PDO::ERRMODE_SILENT, PDO::ERRMODE_WARNING, PDO::ERRMODE_EXCEPTION)

Connect to the database (3) Setting error mode: – setAttribute(PDO::ATTR_ERRMODE,[Error mode]);?> List of error modes: – PDO::ERRMODE_SILENT: Just set error codes (it is the default mode) – PDO::ERRMODE_WARNING: Raise warnings – PDO::ERRMODE_EXCEPTION: Throw exceptions

Query the database using SQL (1) See the figure below to know the steps we must follow to avoid some issue when work with database.

Query the database using SQL (2) Prepare a query. We have some ways to binding data. – prepare('INSERT INTO user(username,password, ) VALUES (?,?,?)'); $data = $st->execute($data);?> – prepare('INSERT INTO user(username,password, ) VALUES (:username,:password,: )'); $data = array('username'=>'test_user', 'password'=>'test_pasword', $st->execute($data);?> – (...)

Query the database using SQL (3) If you want to bind data that it of a different data type (such as integer, boolean or lob), you can use bindParam() method.bindParam() – For 3 rd parameter default is PDO::PARAM_STRING: $query- >bindParam(':username', Test_Username'); – $query->bindParam(':id', $id, PDO::PARAM_INT) You can use exec() method to query but if you want to use prepare() method you must use execute() method.

Do something with result To get data you can use fetch() method to get the next row from a result set or fetchAll() method to get an array containing all of the result set rows.fetch()fetchAll() – query('SELECT * FROM test_table'); $result = $query->fetchAll([fetch_style]);?> We have some fetch styles: – PDO::FETCH_BOTH (it is the default): returns an array indexed by both column name and 0-indexed column number as returned in your result set – PDO::FETCH_ASSOC: returns an array indexed by column name as returned in your result set – PDO::FETCH_OBJ: returns an object – (and another style please see in here)here

Close the connection to the database Close the connection – – We just set the handle to null – PDO does support persistent connections.

PHP SOAP and something you must know first SOAP (Simple Object Access Protocol). is a protocol for accessing web services. It is based on XML. WSDL (Web Services Description Language) is a language for describing web services and how to access them. It is written in XML. XML (eXtensible Markup Language) is designed to transport and store data. In this slide, we will create SOAP Server and SOAP Client with PHP.

The WSDL Document Structure (1) The main structure of WSDL document:

The WSDL Document Structure (2) Elements in WSDL – : this element is the most important WSDL element. It describes a web service, the operations that can be performed, and the messages that are involved. – : this element defines the data elements of an operation. – : this element defines the data types that are used by the web service – : this element defines the data format and protocol for each port type – : this element defines the ports supported by the Web service. For each of the supported protocols, there is one port element. The service element is a collection of ports.

PHP SOAP Server Methods for SoapServer class: – addFunction(): Adds one or more functions to handle SOAP requests – addSoapHeader: Add a SOAP header to the response – handle(): Handles a SOAP request – setClass(): Sets the class which handles SOAP requests – setObject(): Sets the object which will be used to handle SOAP requests – (and another method. To see details, please go here)here

PHP SOAP Client Methods for SoapClient class: – __soapCall(): Calls a SOAP function – __setSoapHeaders(): Sets SOAP headers for subsequent calls – __getFunctions(): Returns list of available SOAP functions – __getLastRequest(): Returns last SOAP request – __getLastRequestHeaders(): Returns the SOAP headers from the last request – __getLastResponse(): Returns last SOAP response – __getLastResponseHeaders(): Returns the SOAP headers from the last response – __doRequest(): Performs a SOAP request

DEMO

Demo source

Q&A