Tutorial: Using PHP, SOAP and WSDL Technology to access a public web service.



Similar documents
WIRIS quizzes web services Getting started with PHP and Java

Working with forms in PHP

c. Write a JavaScript statement to print out as an alert box the value of the third Radio button (whether or not selected) in the second form.

How Changes in MS Internet Explorer Version 8 Will Affect Web Pages Containing Input type=file

Chapter 22 How to send and access other web sites

Configuring iplanet 6.0 Web Server For SSL and non-ssl Redirect

JavaScript and Dreamweaver Examples

Internet Technologies

Hello World RESTful web service tutorial

Further web design: HTML forms

Real SQL Programming 1

Intell-a-Keeper Reporting System Technical Programming Guide. Tracking your Bookings without going Nuts!

PHP AdWords API Lib Quick Start

Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Major Subject

Novell Identity Manager

Mapping ITS s File Server Folder to Mosaic Windows to Publish a Website

Short notes on webpage programming languages

Content Management System

Sample HP OO Web Application

Tool-Assisted Knowledge to HL7 v3 Message Translation (TAMMP) Installation Guide December 23, 2009

Contents. 2 Alfresco API Version 1.0

LICENSE4J AUTO LICENSE GENERATION AND ACTIVATION SERVER USER GUIDE

Stata web services: Toward Stata-based healthcare informatics applications integrated

Published. Technical Bulletin: Use and Configuration of Quanterix Database Backup Scripts 1. PURPOSE 2. REFERENCES 3.

CS412 Interactive Lab Creating a Simple Web Form

SDK Code Examples Version 2.4.2

Installation Document for HTML Calculators

UFTP AUTHENTICATION SERVICE

OrangeHRM Web Installation Guide for Windows

Bubble Code Review for Magento

Quick Start Guide Joomla!: Guidelines for installation and setup. Why Joomla!

HTML Tables. IT 3203 Introduction to Web Development

Digital Downloads Pro

Web Services using Tomcat and Eclipse

Slide.Show Quick Start Guide

How to Install Multicraft on a VPS or Dedicated Server (Ubuntu bit)

PHP Tutorial From beginner to master

Installing the ASP.NET VETtrak APIs onto IIS 5 or 6

Oracle Universal Content Management

A Sample OFBiz application implementing remote access via RMI and SOAP Table of contents

How to Make a Working Contact Form for your Website in Dreamweaver CS3

2- Forms and JavaScript Course: Developing web- based applica<ons

Response Time Analysis of Web Templates

JobScheduler Web Services Executing JobScheduler commands

Monitoring Oracle Enterprise Performance Management System Release Deployments from Oracle Enterprise Manager 12c

MAGEJAM PLUGIN INSTALLATION GUIDE

ZeroTurnaround License Server User Manual 1.4.0

Online Multimedia Winter semester 2015/16

HTML tutorial. Purpose: Importance: Very few people code HTML by hand anymore. There are a multiplicity

Introduction to Websites & Dynamic Content

Instructions for Embedding a Kudos Display within Your Website

CGI Programming. What is CGI?

<Insert Picture Here>

Installing buzztouch Self Hosted

About This Document 3. About the Migration Process 4. Requirements and Prerequisites 5. Requirements... 5 Prerequisites... 5

Lets Get Started In this tutorial, I will be migrating a Drupal CMS using FTP. The steps should be relatively similar for any other website.

4 Understanding. Web Applications IN THIS CHAPTER. 4.1 Understand Web page development. 4.2 Understand Microsoft ASP.NET Web application development

Web and e-business Technologies

Introduction to Web Design Curriculum Sample

Forms, CGI Objectives. HTML forms. Form example. Form example...

Direct Post Method (DPM) Developer Guide

Omnistar Recruiter Install User Guide (Codelock)

Web services can convert your existing applications into web applications.

White Paper Using PHP Site Assistant to create sites for mobile devices

Designing for Dynamic Content

CycleServer Grid Engine Support Install Guide. version 1.25

MySQL Quick Start Guide

CPE111 COMPUTER EXPLORATION

End of Sale/End of Life Report Tool Usage Notes for CiscoWorks NCM 1.6

CloudPortal Services Manager Version 11.0 CU2 Deployment Guide

Accessing Data with ADOBE FLEX 4.6

Code Estimation Tools Directions for a Services Engagement

Scritto da Administrator Lunedì 02 Gennaio :27 - Ultimo aggiornamento Lunedì 02 Gennaio :52

Write a Web Application for Free Edition 2

MySQL quick start guide

MySQL Quick Start Guide

Address Phone & Fax Internet

TARGETPROCESS INSTALLATION GUIDE

Deploying Microsoft Operations Manager with the BIG-IP system and icontrol

Client-side Web Engineering From HTML to AJAX

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

HTML Forms and CONTROLS

RaidenFTPD Log Analyser Web Edition

NGASI AppServer Manager SaaS/ASP Hosting Automation for Cloud Computing Administrator and User Guide

Web Server Lite. Web Server Software User s Manual

The Basics of Dynamic SAS/IntrNet Applications Roderick A. Rose, Jordan Institute for Families, School of Social Work, UNC-Chapel Hill

by

How to consume a Domino Web Services from Visual Studio under Security

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

XHTML BASICS. Institute of Finance Management CIT Department Herman Mandari

Inserting the Form Field In Dreamweaver 4, open a new or existing page. From the Insert menu choose Form.

Java Access to Oracle CRM On Demand. By: Joerg Wallmueller Melbourne, Australia

Here, we will discuss step-by-step procedure for enabling LDAP Authentication.

Web Programming with PHP 5. The right tool for the right job.

Website Implementation

How to Display Weather Data on a Web Page

17 March 2013 NIEM Web Services API Version 1.0 URI:

Lesson 7 - Website Administration

a) Install the SDK into a directory of your choice (/opt/java/jdk1.5.0_11, /opt/java/jdk1.6.0_02, or YOUR_JAVA_HOME_DIR)

Consuming and Producing Web Services with WST and JST. Christopher M. Judd. President/Consultant Judd Solutions, LLC

Transcription:

Tutorial: Using PHP, SOAP and WSDL Technology to access a public web service. ** Created by Snehal Monteiro for CIS 764 ** In this small tutorial we will access the Kansas Department of Revenue's web service to get sales tax information for a particular area in Kansas. We just send the Zip Code of a particular area in Kansas to the web service and it returns the sales tax for that region. Pre-requisites: 1)The server should support PHP. Since the server for the CIS Department supports PHP scripts, this would not be a problem for us. 2)All our html and php documents will be saved in the public_html folder in the U drive. 3)A text editor like notepad where we write html and php code. Tutorial Steps: There are 4 major steps involved: 1) Creating a simple HTML page, which has just one text box to enter the Zip Code. 2) Download the nusoap.php document and save it the public_html folder. 3)Create the gettax.php which will access the web service using WSDL(Web Service Desription Language) file published by the Kansas Department of Revenue. 4)Run the web application. 1)Creating a simple HTML page, which has just one text box to enter the Zip Code: Copy paste or type the following code in a note-pad and save the file as gettax.html in the public_html folder.

<html> <head> <title>get Tax Details</title> </head> <body> <b><font size="4">enter Zip Code of a region in Kansas and hit submit to get sales tax details for that particular region:</font></b> <form name="form1" method="post" action="gettaxdetails.php"> <p>enter Zip Code: <input name="zip" type="text" id="zip" size="20"> </p> <p> <input type="submit" name="submit" value="submit"> </p> </form> </html> After opening the gettax.html page in the browser you can see the following web page:

2)Download the nusoap.php document and save it the public_html folder: Here we access nusoap.php which is open-source and available freely. We reference the nusoap.php document in our gettaxdetails.php. 1] Click on this link: http://dietrich.ganx4.com/nusoap/index.php 2] Navigate through the web-site. Click on the nusoap-0.7.3.zip file and download it. 3] Unzip the nusoap-0.7.3.zip file. 4]Then open the folder nusoap-0.7.3. Then open the lib folder. You will see many php documents inside the lib folder.copy the file named nusoap.php and paste it in the public_html folder. nusoap-0.7.3.-> lib-> nusoap.php 3)Create the gettax.php which will access the web service using WSDL(Web Service Desription Language) file published by the Kansas Department of Revenue: Copy paste or type the following code in note-pad and save the file as gettaxdetails.php in your public_html folder: ------------- Code starts here---------------- <? # Query the Kansas Department of Revenue and Retrieve Tax Rates # First, we need to bring in the library file. The require_once command will make sure the functions are only added once into our script. require_once('nusoap.php'); #Next step we will define where the WSDL is located and create an instance of the soapclient class to access the web service. $wsdl="http://services.taxwatch.biz/rates/kansas/sstp.wsdl"; $client=new soapclient($wsdl, 'wsdl'); $zip = $_POST['Zip'];

# We then send in two parameters through the SOAP client: the zipcode and date $param=array( 'intzipcode' => $zip, 'dtpaymentdate' => '2007-10-19' ); # Finally, the web service responds with the result of our query wrapped in a SOAP message. $result = $client->call('getfipsby5ziponly', $param); $FIPSRecordList = $result['fipsrecordlist']; print_r($result); $stategeneraltaxrateintrastate = $FIPSRecordList[0]['strGeneralTaxRateIntrastate']; $countygeneraltaxrateintrastate = $FIPSRecordList[1]['strGeneralTaxRateIntrastate']; $citygeneraltaxrateintrastate = $FIPSRecordList[2]['strGeneralTaxRateIntrastate']; $GeneralTaxRateIntrastate = $stategeneraltaxrateintrastate + $countygeneraltaxrateintrastate + $citygeneraltaxrateintrastate; echo "<p>total General Tax Rate for Zip Code $zip = ". $GeneralTaxRateIntrastate. '%</p>';?> ------------------------- Code ends here--------------------------- 4)Run the web application: Any files to be accessed by the web server must be publically readable, but none of your PHP files (nor the directory containing them) may be group or publically writable. Following are the commands you can use for setting the permissions in linux: chmod 644 public_html/gettaxdetails.php chmod 644 public_html/nusoap.php

Now type the gettax.html URL in your browser.you will see the following page: Then enter any Zip Code from Kansas in the text box:

Then you hit submit.you should get the following output: The highlighted part shows the Sales Tax as 6.3 % for Zip Code 66502

In this Tutorial we learnt that accessing and using a web-service is very easy. Key Concepts: 1) Web services allow you to share data across many platforms and hardware configurations. For example, you can create a Java web service and someone else can consume it using a.net client without having to learn one line of Java code. 2) WSDL stands for Web Services Description Language, an XML file which describes the interface of a web service. We used the WSDL file published by the Kansas Department of Revenue. We observe the parameters in this WSDL and write our php script accordingly. 3) SOAP is designed as an XML wrapper for web services requests and responses.nusoap is a powerful API developed for the PHP platform.the required libraries are contained in a file called nusoap.php. 4) In our tutorial we used SOAP (nusoap.php) to access a web-service, which is described as a WSDL published by the Kansas Department of Revenue. 5) Description of the Kansas Department of Revenue web service can be found out at the following link https://www.taxwatch.biz/cgi-win/kansas/txwstatesite.exe/lookups