7/10/2007 AIIT Summer Course - D# 1 Wireless Embedded Systems and Networking Lab Day 2: Part 2: Custom IP/USN application via Web Services Lab Assistant:

Slides:



Advertisements
Similar presentations
Message Passing Vs Distributed Objects
Advertisements

Presentation 10 SOAP on the Microsoft Platform (.NET)
1 CGICGI Common Gateway Interface Server-side Programming Lecture.
7/9/2007 AIIT Summer Course - D# 1 Wireless Embedded Systems and Networking Lab Day 1: Part 2: Build a self-organized mesh over a physical extent. Lab.
COEN 445 Communication Networks and Protocols Lab 4
PHP Programming with MySQL Slide 2-1 CHAPTER 2 Getting Started with PHP.
MC365 Application Servers: Servlets. Today We Will Cover: What a servlet is The HTTPServlet and some of its more important methods How to configure the.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
Lecture 10: Web Services. Outline Overview of Web Services Create a Web Service with Sun J2EE (JAX-RPC)
7/10/2007 AIIT Summer Course - D# 1 Wireless Embedded Systems and Networking Lab Day 2: Part 3: Custom analysis of the networking Lab Assistant: Jaein.
EEC-681/781 Distributed Computing Systems Lecture 5 Wenbing Zhao Department of Electrical and Computer Engineering Cleveland State University
7/13/2007AIIT Summer Course - D#1 Wireless Embedded Systems and Networking Lab Day 5: Part 1: TinyOS Programming on Open Source Distribution Jaein Jeong.
Creating WordPress Websites. Creating a site on your computer Local server Local WordPress installation Setting Up Dreamweaver.
7/10/2007 AIIT Summer Course - D# 1 Wireless Embedded Systems and Networking Lab Day 2: Part 1: Add your own external sensors Lab Assistant: Jaein Jeong.
7/10/2007 AIIT Summer Course - D# 1 Wireless Embedded Systems and Networking Lab Day 3: Solution to SOAP client examples Jaein Jeong University of California,
7/11/2007 AIIT Summer Course - D# 1 Wireless Embedded Systems and Networking Lab Day 3: Part 1: IP access using standard client programs Lab Assistant:
Hypertext Transport Protocol CS Dick Steflik.
Chapter 13 XML Concept of XML Simple Example of XML XML vs. HTML in Syntax XML Structure DTD and CDATA Sections Concept of SAX Processing Download and.
Java Servlets and JSP.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
INTRODUCTION TO WEB DATABASE PROGRAMMING
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Web Servers1-1 Web Servers Xingquan (Hill) Zhu
1 Java Programming II Java Network II (Distributed Objects in Java)
SSC2: Web Services. Web Services Web Services offer interoperability using the web Web Services provide information on the operations they can perform.
Grid Computing, B. Wilkinson, 20043b.1 Web Services Part II.
CSE 305 Theory of Database Tutorial on Connecting with Sybase from Java program and Developing GUI Jalal Mahmud, TA, CSE 305.
11/16/2012ISC329 Isabelle Bichindaritz1 Web Database Application Development.
CSCI 6962: Server-side Design and Programming Web Services.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
1 Apache. 2 Module - Apache ♦ Overview This module focuses on configuring and customizing Apache web server. Apache is a commonly used Hypertext Transfer.
Python and REST Kevin Hibma. What is REST? Why REST? REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
HTML. Principle of Programming  Interface with PC 2 English Japanese Chinese Machine Code Compiler / Interpreter C++ Perl Assembler Machine Code.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
Chapter 18 Networking F Client/Server Communications F Simple Client/Server Applications F Serve Multiple Clients F Create Applet Clients F Send and Retrieve.
Presentation: SOAP/WS in a distributed object framework, Application Servers & AXIS SOAP.
Apache, MySQL and PHP Installation and Configuration Chapter 1 Apache Installation and Configuration.
7/9/2007 AIIT Summer Course - Lab Wireless Embedded Systems and Networking Lab Day 1: Part 1: First Table-top IP/WSN Lab Assistant: Jaein Jeong University.
Integrating and Troubleshooting Citrix Access Gateway.
1 Session 1: Introduction to PHP & MySQL iNET Academy Open Source Web Development.
A FIRST TOUCH ON NOSQL SERVERS: COUCHDB GENOVEVA VARGAS SOLAR, JAVIER ESPINOSA CNRS, LIG-LAFMIA, FRANCE
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
CITA 310 Section 7 Installing and Testing a Programming Environment (Textbook Chapter 7)
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Web Services An Introduction Copyright © Curt Hill.
1 G52IWS: Example Web-services Chris Greenhalgh. 2 Contents Software requirements AXIS web service run-time components Getting started with Jetty & AXIS.
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.
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
PHP Syntax You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain.
Net-centric Computing Web Services. Lecture Outline  What is Web Service  Web Service Architecture  Creating and using Java Web Services  Apache Axis.
CS422 Principles of Database Systems JDBC and Embedded SQL Chengyu Sun California State University, Los Angeles.
CISC103 Web Development Basics: Web site:
Course Outcomes of Advanced Java Programming AJP (17625, C603)
Unit – 5 JAVA Web Services
Hypertext Transport Protocol
Web UI Basics ITM 352.
PHP / MySQL Introduction
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
Lecture 5: Functions and Parameters
Java Servlets and JSP.
Python and REST Kevin Hibma.
Presentation transcript:

7/10/2007 AIIT Summer Course - D# 1 Wireless Embedded Systems and Networking Lab Day 2: Part 2: Custom IP/USN application via Web Services Lab Assistant: Jaein Jeong University of California, Berkeley

7/10/2007AIIT Summer Course - D#2 REST (Representational State Transfer) API –Clients access Gateway through HTTP GET or POST. –Response is in XML and can be parsed by clients. –Easy to start with: just needs web browser. SOAP (Simple Object Access Protocol) API –Clients access Gateway using host programming language (e.g. java, php, C/C++) through SOAP library. –Response is parsed into host PL format by SOAP library. –Takes some time to start, but easier to integrate with host programming language. Compare REST and SOAP

7/10/2007AIIT Summer Course - D#3 Some Examples of REST Assuming the Gateway Server is Get the Last Temp. Readings from the Sensors – =TemperatureReadEvent Change the Sensor Sample Period – amplePeriod – amplePeriod&value= Ping a Node – ffffffffffffffff

7/10/2007AIIT Summer Course - D#4 List of REST API

7/10/2007AIIT Summer Course - D#5 Using SOAP Host Programming Language to Use –Java, php, C/C++, C#, perl, python Step 1: Install Development Kit –JDK, Php development kit, C/C++ compiler Step 2: Install SOAP library and client stubs Step 3: Accessing SOAP in host programming language.

7/10/2007AIIT Summer Course - D#6 Using SOAP with Java Step 1: Install JDK Step 2a: Install SOAP library –Apache Axis, commons-httpclient-3.0-rc3.jar, commons- codec-1.3.jar –Add library to CLASSPATH. Step 2b: Create SOAP client stubs –Java org.apache.axis.wsdl.WSDL2Java “ Step 3a: Acquiring gateway port –GWServiceLocator locator = new GWServiceLocator(); –GWPort proxy = locator.getGWPort(portURL); Step 3b: Sending a request to gateway –GW__PingNode_Result[] results; –results = proxy.mgmtPingNode(addr, 1, TIMEOUT, “*”); –System.out.println(results[i].getLongAddr());

7/10/2007AIIT Summer Course - D#7 Using SOAP with PHP Step 1, 2: Install PHP development kit –Select SOAP as an external component. –Do not select other external components (bug?). Step 3a: Acquiring gateway port –$url = $gateway. “/gw/rest/V1/?method=gw.getWSDL”; –$proxy = new SoapClient($url); Step 3b: Sending a request to gateway –$ret = $proxy->mgmtPingNode(“ffffffffffffffff”, 2, “*”);

7/10/2007AIIT Summer Course - D#8 SOAP API

7/10/2007AIIT Summer Course - D#9 Example: Get the last temperature readings from sensors (Java) Corresponding REST call – =TemperatureReadEvent Start from a sample application (e.g. Get.java) Modify the method invocation. results = proxy.attributesGet(name, addr, TIMEOUT, "*");

7/10/2007AIIT Summer Course - D#10 Example: Get the last temperature readings from sensors (Java) Find the name of method. – Find the signature for the method. Declare any data structure required. $ grep -n "eventsReadLast(" *java GWPort.java:27: public gw.GW__eventsReadLast_Result eventsReadLast(java.lang.String name, java.lang.String addr) throws java.rmi.RemoteException;

7/10/2007AIIT Summer Course - D#11 Example: Get the last temperature readings from sensors (Java) public void get(String name, String addr) { GW__eventsReadLast_Result result; GW__Event_Result[] results; GW__Event value; try { result = proxy.eventsReadLast(name, addr); results = result.getResults(); for (int i = 0; i < results.length; i++) { value = results[i].getValue(); System.out.println( "Mote " + results[i].getAddr() + " Time " + results[i].getTimestamp() + " " + name + " " + value.getTemperatureReadEvent() ); } catch (Exception e) { e.printStackTrace(); System.exit(2); } } 1. Intermediate data type declaration 2. Method Invocation 3. Reading Results

7/10/2007AIIT Summer Course - D#12 Example: Get the last temperature readings from sensors (Java) Results $ java GetLastTemperature Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled. Mote 00173b000fecb28f Time E9 TemperatureReadEvent 7246 Mote 00173b Time E9 TemperatureReadEvent 7297

7/10/2007AIIT Summer Course - D#13 Example: Get the last temperature readings from sensors (PHP) REST call – =TemperatureReadEvent Find method as in Java. –Same as Java »Method name, member variable name –Different from Java »No explicit type declaration. »Member variables are accessed directly, not through methods as in Java.

7/10/2007AIIT Summer Course - D#14 Example: Get the last temperature readings from sensors (PHP) function get($gateway, $attrName, $mote) { $url = " $gateway. "/gw/rest/V1/?method=gw.getWSDL"; $proxy = new SoapClient($url); $ret = $proxy->eventsReadLast($attrName, $mote); $ret_arr = $ret->results; foreach ($ret_arr as $result) { echo "Mote ". $result->addr. " Time ". $result->timestamp. " ". $attrName. " ". $result->value->TemperatureReadEvent."\n"; } $ php get_last_temperature.php Mote 00173b000fecb28f Time TemperatureReadEvent 7252 Mote 00173b Time TemperatureReadEvent 7304 Results Source Code

7/10/2007AIIT Summer Course - D#15 Exercises Write at least two applications either in Java or PHP. Download skeleton code from the built server. –Java: Ex2_1.java, Ex2_2.java, …, Ex2_6.java –PHP: ex2_1.php, ex2_2.php, …, ex2_6.php Complete the code by filling in the TODO in the skeleton code.

7/10/2007AIIT Summer Course - D#16 Exercise-1 Get the Names of Nodes –REST Call: $ java Ex2_ (or php ex2_1.php ) - Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled. Mote 00173b000c Name 14fourteen Mote 00173b000c Name 12twelve Mote 00173b000c847d22 Name 13thirteen Mote 00173b000fecb28f Name Node 00173b000fecb28f Mote 00173b e21 Name 2two Mote 00173b ef Name 6six Mote 00173b Name Node 00173b Mote 00173b d2 Name 1one Mote 00173b f7 Name 3three Mote fffffffffffffffe Name SnIPSnap

7/10/2007AIIT Summer Course - D#17 Exercise-2 Get the Locations of the Nodes – $ java Ex2_ (or php ex2_2.php ) - Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled. Mote 00173b000c map-x 170 Mote 00173b000c map-x 20 Mote 00173b000c847d22 map-x 170 Mote 00173b000fecb28f map-x 180 Mote 00173b e21 map-x 90 Mote 00173b ef map-x 170 Mote 00173b map-x 185 Mote 00173b e21 map-x 90 Mote 00173b ef map-x 170 Mote 00173b map-x 185 Mote 00173b d2 map-x 90 Mote 00173b f7 map-x 330 Mote fffffffffffffffe map-x 20 Mote 00173b000c map-y 270 Mote 00173b000c map-y 420 Mote 00173b000c847d22 map-y 355 Mote 00173b000fecb28f map-y 170 Mote 00173b e21 map-y 270 Mote 00173b ef map-y 180 Mote 00173b map-y 345 Mote 00173b d2 map-y 180 Mote 00173b f7 map-y 100 Mote fffffffffffffffe map-y 380

7/10/2007AIIT Summer Course - D#18 Exercise-3 Get All Data in a Recent Time Window (1 day) – &t2Offset=0 $ java Ex2_ (or php ex2_3.php ) - Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled. Mote 00173b timestamp E9 TemperatureReadEvent 7281 Mote 00173b000fecb28f timestamp E9 TemperatureReadEvent 7227 Mote 00173b timestamp E9 TemperatureReadEvent 7281 Mote 00173b000fecb28f timestamp E9 TemperatureReadEvent 7225 …

7/10/2007AIIT Summer Course - D#19 Exercise-4 Request a Sample from All Enabled Sensors – quest $ php ex2_4.php (or java Ex2_ ) Mote 00173b000fecb28f Time Mote 00173b000c Time Mote 00173b e21 Time Mote 00173b d2 Time Mote 00173b000c Time Mote 00173b000c847d22 Time Mote 00173b f7 Time Mote 00173b Time Mote 00173b ef Time

7/10/2007AIIT Summer Course - D#20 Exercise-5 Get the Battery Voltage of the Nodes – tatsEvent $ php ex2_5.php (or java Ex2_ ) Mote 00173b d2 Time Voltage 2999 Mote 00173b000c847d22 Time Voltage 2965 Mote 00173b e21 Time Voltage 2999 Mote 00173b f7 Time Voltage 2999 Mote 00173b000c Time Voltage 2999 Mote 00173b000fecb28f Time Voltage 2999 Mote 00173b000c Time Voltage 2999 Mote 00173b Time Voltage 2852 Mote 00173b ef Time Voltage 2999

7/10/2007AIIT Summer Course - D#21 Exercise-6 Get Statistics on Node Traffic and Network Reliability – deStatsEvent&t1Offset=-86400&t2Offset=0 $ php ex2_6.php (or java Ex2_ ) Mote 00173b000c timestamp sent 1512 delivered 1428 Mote 00173b d2 timestamp sent 1477 delivered 1425 Mote 00173b timestamp sent 1783 delivered 1745 Mote 00173b000fecb28f timestamp sent 2222 delivered 2098 Mote 00173b000c timestamp sent 1471 delivered 1422 Mote 00173b ef timestamp sent 1503 delivered 1433 Mote 00173b f7 timestamp sent 1476 delivered 1415

7/10/2007AIIT Summer Course - D#22 TO-DO list for PHP Web Service Install PHP –Tested with php win32-installer. Install Apache Web Server –Tested with apache_ win32-x86-no_ssl. –Configure httpd.conf file to active PHP in the web server. –Move PHP source code to the web server root directory. »C:\Program Files\Apache Group\Apache2\htdocs # For PHP 5 do something like this: LoadModule php5_module "c:/Program Files/PHP/php5apache2.dll" AddType application/x-httpd-php.php # configure the path to php.ini PHPIniDir "C:/Program Files/PHP"

7/10/2007AIIT Summer Course - D#23 PHP Web Service Example Connects to the gateway server. Lists sensor reading for a node

7/10/2007AIIT Summer Course - D#24 CMD PHP vs. web-based PHP Command Line PHPWeb-based PHP Command Line Passing Cmd line parameters. e.g. $gateway = $argv[1]; Named parameters. E.g. Caller: $ip E.g. Callee: $server = $_GET['server']; Debugging Both program result and error on console. Program result on web browser. Error on web server error log. Etc Nested variables allowed. E.g: echo $result->value-> NodeStatsEvent->voltage; Nested variables should be declared in cascade for access. E.g. $value = $result->value; $event = $value-> NodeStatsEvent; echo $event->voltage;

7/10/2007AIIT Summer Course - D#25 PHP Web Service Example Exercise 2-7: Modify get_last_temperature_web.php so that it displays temperature in Celsius rather than Fahrenheit.