• Ei tuloksia

Implementing Web Services for Sensor Information

4. MIDDLEWARE APPROACH TOWARDS SENSOR MONITORING SERVICE

5.3 Implementing Web Services for Sensor Information

The Web Services are programmed under PHP using NuSOAP [68] which is set of classes to develop and consume Web Service in SOAP and WSDL. The defined web services performs parameter value requested from mobile client, each parameter value runs select query on database table according to requested sensor from client mobile interface. Figure 25 shows the message sequence chart (MSC) of mobile client and web services. The client initiate connection to the web server as shown in Figure 25, after successful connection screen two on mobile interface allows user to select the sensor nodes to view its information by sending parameter value for example ‘a’ for sensor 1.

The web service connects to database and runs the query for specific sensor, and return sensor data result to the web service. Final stage of messaging is the web service returns the sensor information to mobile client in XML/SOAP format. Figure 29 and 30 gives the overview how the result display on mobile client interfaces.

Figure 25. MSC between Mobile client and web services 5.4 Client Interfaces Web based & Mobile based

The interfaces for client to view sensor information are browser based and mobile phone based. The web based interface is where client can view all the information from sensor database through web browser. Browser based client can also view the generated graph of sensor information showing for example temperature changes in week or month on specific sensor. The web interface is developed with PHP are login screen page shown in Figure 26, view data page shown in Figure 27 and view graph page shown in Figure 28.

Figure 26. Login screen for sensor view

Figure 27. Sensor View Page

Figure 28. Sensor Graph View Page

Second interface is Mobile client in Windows Mobile (WM) which facilitates mobile client users. Mobile client can check only current status of provided sensor through his mobile phone as shown in Figure 29 and Figure 30. The programming language used for mobile interface and event actions is done in C#.

Figure 29. Mobile Initial Screen Figure 30. Sensor Info Screen

6. CONCLUSIONS

The primary objective of the thesis was to develop gateway monitoring application for infrastructure sensor networks. Real time monitoring system based on wireless sensor networks and its application has been studied. A feasible application has been developed which can fit from normal to average use of home or small scale area monitoring.

The overall topic of wireless sensor network has different level of research areas such as of MAC layer, nodes and protocol security, routing enhancement protocol to energy efficiency. The main focus in this thesis work was to develop monitoring application for wireless sensor network. Therefore sensor middlewares are reviewed based on different approaches such as Microsoft research project SenseWeb which acts like a common sensor data repository and application such as SensorMap that is build on top of it using the sensor data. In addition Open GIC Consortium (OGC) has been studied, which introduce Sensor Web Enablement (SWE) concept providing actually a set of specifications. These specifications include Sensor Markup Language, Observation &

Measurement, Sensor Collection Service, Sensor Planning Service and Web Notification Service to implement the Sensor Web. The Open Sensor Web Architecture (OSWA) extends the SWE and integrates the Sensor Web and grid computing by providing middleware support for Sensor Web. Also concept of Service Oriented Architecture approach is studied and used as key development method in thesis project work, which is useful method to describe and invoke services on heterogeneous platform using SOAP and XML standard.

The initial challenge in the project work was faced with setting up development environment for SunSPOT, although the technical documentation refer that Netbeans 6.0 can be configured in Linux for SunSPOT. The basestation doesn’t respond properly under Linux although it works better in Windows OS. Another challenge was faced in configuring the Crossbow Micaz sensor to store data in PostgreSQL 8.4. This problem was tackled by changing the configuration script of XMTS400 sensor board. Finally for selecting the web service framework after testing Apache Axis 2 and .Net Framework,

NuSOAP was chosen because it provides yet powerful and simple web service framework with easily deployed and development methods.

The developed application suits well for standard infrastructure sensor monitoring and applicable in the home or small scale of environment monitoring. In the work is used environmental sensors to measure temperature, light, humidity, accelerometer-degree and the developed system is excellent example of real time system and its monitoring. This thesis work can be further enhanced by creating common protocol for both Micaz and SunSPOT sensor networks, making possible to apply single basestation node for both sensor networks. Another enhancement could be a middleware test bed to integrate different or heterogeneous sensor data and provide common API for all sensors nodes.

REFERENCES

[1] Jeremy Elson and Deborah Estrin,Sensor networks: a bridge to the physical world, Center for Embedded Networked Sensing, University of California, Wireless Sensor Networks, p.p. 3-20, 2004 ACM, ISBN:1-4020-7883-8.

[2] Shijin Dia, Xiaorong Jing, Lemin Li,Research and analysis on Routing Protocols for Wireless Sensor Networks,Proceedings of International Conference on Communications, Circuits and Systems, p.p.407-411, University of Electronics Science and Technology of China, May 2005 IEEE, ISBN: 0-7803-9025-6.

[3] Chonggang Wang; Sohraby, K.; Daneshmand, M.; Bo Li, Yueming Hu, Arkansas Univ., AR, USA, A Survey Of Transport Protocols For Wireless Sensor Networks, IEEE Network, p.p. 34-40, June 2006 IEEE, ISSN: 0890-8044.

[4] Holger Karl and Andreas Willig , Protocols and Architecture for Wireless Sensor Networks,. John Wiley & Sons Ltd 2005. ISBN: 0-470-09510-5.

[5] Chee-Yee Chong, Kumar, S.P. Booz Allen Hamilton,Sensor networks: evolution, opportunities, and challenges, Proceeding of IEEE, p.p. 1247-1256, August 2003 IEEE, ISSN: 0018-9219.

[6] Stefano B, Marco C, Silvia G, Ivan S,Mobile Ad Hoc Networking, ‘Mobile ad-Hoc networking with a View of 4G Wireless’, John Wiley & Sons Ltd 2004 , ISBN: 0-0471-37313-3

[7] Seapahn Meguerdichian, Farinaz Koushanfar, Miodrag Potkonjak, Mani B.

Srivastava,Coverage Problems in Wireless Ad-hoc Sensor Networks, Poceedings of IEEE. INFOCOM 2001. Twentieth Annual Joint Conference of the IEEE Computer and Communications Societies. p.p. 1380-1387 vol.3,University of California LA, IEEE 2001, ISBN: 0-7803-7016-3.

[8] Kyildiz, I.F, Weilian Su, Sankarasubramaniam, Y Cayirci,A Survey On Sensor Networks, IEEE Communications Magazine, p.p. 102-114 vol.40, Atlanta, GA, August 2002 IEEE, ISSN: 0163-6804.

[9] Chris Townsend, Steven Arms, Sensor Technology Handbook, ‘Principles and Applications’. MicroStrain, Inc. Book 2005, ISBN: 0-7506-7729-5.

[10] José Carlos , Teresa Olivares and Luis Orozco-Barbosa,Routing protocols for wireless sensor networks-based network, Technical Report,Albacete Research Institute of Informatics University of Castilla-La Mancha [pdf: accessed 08.07.2010]

(http://www.dsi.uclm.es/descargas/thecnicalreports/DIAB-07-06-1/tehcnicalreport.pdf)

[11] Kemal Akkaya and Mohamed Younis,A Survey On Routing Protocols For Wireless Sensor Networks, Ad Hoc Networks, vol 3, Issue 3, May 2005, p.p. 325-349 , Elsevier, ISSN: 1570-8705

[12] W. Heinzelman, J. Kulik and H. Balakrishnan, Adaptive Protocols for Information Dissemination in Wireless Sensor Networks, Proceedings of the 5th annual ACM/IEEE international conference on Mobile computing and networking, p.p 174-185, Seattle, Washington, USA 1999,ACM, ISBN: 1-58113-142-9.

[13] Md. Habibe Azam, Abdullah-Al-Nahid, Md. Abdul Alim, Md. Ziaul Amin, A Survey and Comparison of Various Routing Protocols of Wireless Sensor Network (WSN) and a Proposed New TTDD Protocol Based on LEACH,(IJCNS) International Journal of Computer and Network Security, Vol. 2, No. 8, August 2010.

[14] Lindsey, S. Raghavendra,PEGASIS: Power-efficient gathering in sensor

information systems, Proceedings Aerospace Conference, 2002. IEEE, p.p 1125 - 3-1130 vol.3 , Los Angeles, CA, USA , IEEE 2002, ISBN: 0-7803-7231-X.

[15] Laiali Almazaydeh, Eman Abdelfattah, Manal Al- Bzoor, and Amer Al- Rahayfeh, Performance Evaluation of Routing Protocol in Wireless Sensor Networks,

International Journal of Computer Science and Information Technology, Volume 2, Number 2, April 2010.

[16] Yu Y, Govindan R, Estrin D,Geographical and energy aware routing: A recursive data dissemination protocol for wireless sensor networks,UCLA Computer Science Department Technical Report UCLA/CSDTR-01-0023, Citeseer May 2001.

[17] Yongling Guo; Qianping Wang; Hai Huang; Wei Tan; Guoxia Zhang,

The Research and Design of Routing Protocols of Wireless Sensor Network in Coal Mine Data Acquisition,International Conference on Information Acquisition, 2007. ICIA '07.

July 2007,p.p. 25 - 28, China ,Xuzhou, July 2007 IEEE, ISBN: 1-4244-1220-X.

[18] McDermott-Wells, P., "What is Bluetooth?,"Potentials, IEEE , vol.23, no.5, pp.

33-35, Dec. 2004-Jan. 2005, ISSN: 0278-6648.

[19] Timmons, N.F.; Scanlon, W.G.;Fac. of Eng., Letterkenny , Analysis of The

Performance of IEEE 802.15.4 For Medical Sensor Body Area Networking,First Annual IEEE Communications Society Conference on Sensor and Ad Hoc Communications and Networks, 2004. IEEE SECON 2004. p.p. 16-24, Ireland, IEEE 2004, ISBN: 0-7803-8796-1.

[20] Bob Heile, “ZigBee Alliance Overview”ZigBee Tutorials,

[http://www.zigbee.org/LearnMore/Tutorials.aspx]. Accessed 22 August 2010

[21] Nemeth-Johannes, J.; Sweetser, V.; Sweetser, D.;Implementation of an ieee1451.0/1451.5 compliant wireless sensor module, IEEE Autotestcon 2007,p.p.364 -371,Baltimore, MD , IEEE 2007. ISSN: 1088-7725.

[22] Mainwaring, J. Polastre, R. Szewczyk, D. Culler, and J. Anderson, “Wireless Sensor Networks for Habitat Monitoring”, Proceedings of the 1st ACM international workshop on Wireless sensor networks and applications 2002,Atlanta, Georgia, USA, p.p. 88 - 97 , ACM, ISBN:1-58113-589-0.

[23] K. Martinez, R. Ong, J. K. Hart, and J. Stefanov, “Glacsweb: a sensor network for hostile environments”, First Annual IEEE Communications Society Conference on Sensor and Ad Hoc Communications and Networks, 2004. IEEE SECON 2004, p.p. 81-87, IEEE, ISBN: 0-7803-8796-1

[24] F. Michahelles, P. Matter, A. Schmidt, and B. Schiele, “Applying Wearable Sensors to Avalanche Rescue”,Computers and Graphics, Volume 27, Number 6, pp. 839-847, December 2003.

[25] H. Baldus, K. Klabunde, and G. Muesch, “Reliable Set-Up of Medical Body-Sensor Networks”,Proc. EWSN 2004, Berlin, Germany, pp. 353-363, January 19-21, 2004.

[26] F. Ye, H. Luo, J. Cheng, S. Lu, and L. Zhang, “A two-tier data dissemination model for large-scale wireless sensor networks”,Proceedings of the 8th Annual International Conference on Mobile Computing and Networking, September 23-28, 2002, Atlanta, Georgia, USA, pp. 148–159, ACM Press, 2002.

[27] Woo Kwon Koo, Hwaseong Lee, Yong Ho Kim, Dong Hoon Lee,Implementation and Analysis of New Lightweight Cryptographic Algorithm Suitable for Wireless Sensor Networks,Proceedings of the 2008 International Conference on Information Security and Assurance, p.p. 73-76, Busan 2008, IEEE Computer Society. ISBN:978-0-7695-3126-7.

[28] Taeshik Shon Bonhyun Koo Hyohyun Choi ,Yongsuk Park, U-Convergence Lab., Samsung Electron.,Security Architecture for IEEE 802.15.4-based Wireless Sensor Network, Wireless Pervasive Computing, 2009. ISWPC 2009. 4th International

Symposium on Suwon, p.p. 1-5,Melbourne 2009, IEEE 2009, ISBN: 978-1-4244-2965-3.

[29] Sharifi, M.; Ardakani, S.P.; Kashi, S.S., SKEW: An efficient Self Key Establishment protocol for Wireless sensor networks,International Symposium on Collaborative Technologies and Systems, 2009. CTS '09, Baltimore, MD, 18-22 May 2009, p.p. 250-270, IEEE 2009, ISBN: 978-1-4244-4584-4.

[30] Agustinus Borgy Waluyo, Isaac Pek, Xiang Chen, Wee-Soon Yeoh

SLIM: A Secured Lightweight Interactive Middleware for Wireless Body Area Network, 30th Annual International IEEE EMBS Conference Vancouver, British Columbia, Canada, August 20-24, 2008, p.p. 1821-1824, IEEE 2008, ISBN: 978-1-4244-1814-5.

[31] Holger Karl and Andreas Willig Protocols and Architecture for Wireless Sensor Networks, ‘Single-Node Architecture’, John Wiley & Sons Ltd 2005. ISBN: 0-470-09510-5.

[32]Corssbow 2007 Wireless Product Catlog, PDF (accessed 11.March.2010)

[http://www.investigacion.frc.utn.edu.ar/sensores/Equipamiento/Wireless/Crossbow_Wir eless_2007_Catalog.pdf]

[33]XServe Users Manual(Crossbow Inc), PDF (accessed 11.March.2010)

[http://www.xbow.com.cn/LinkClick.aspx?fileticket=UjCWY6KXa78%3D&tabid=121]

[34] Sun™ Small Programmable Object Technology (Sun SPOT) Developer's Guide, PDF (accessed 05.August.2010),

[http://www.sunspotworld.com/docs/Purple/spot-developers-guide.pdf]

[35] Sun™ Small Programmable Object Technology (Sun SPOT) Theory of Operation, PDF (accessed 07.August.2010)

[http://sunspotworld.com/docs/Purple/SunSPOT-TheoryOfOperation.pdf]

[36] Vlado Handziski, Joseph Polastrey, Jan Hinrich Hauer, Cory Sharpy, Adam Wolisz and David Cullery, Flexible Hardware Abstraction for Wireless Sensor Networks, Proceedings of the Second European Workshop on Wireless Sensor Networks, 2005, p.p. 145-157, IEEE 2005, ISBN: 0-7803-8801-1.

[37] Adi Mallikarjuna Reddy V AVU Phani Kumar, D Janakiram, and G Ashok Kumar, Operating Systems for Wireless Sensor Networks: A Survey Technical Report ,

International Journal of Sensor Networks (IJSNet), Vol. 5, No. 4 2009, pp. 236 – 255.

ACM, ISSN: 1748-1279

[38] Mauri Kuorilehto, Timo Alho , Marko Hännikäinen, and Timo D. Hämäläinen, SensorOS: A New Operating System for Time Critical WSN Applications, Proceedings of the 7th international conference on Embedded computer systems: architectures,

modeling, and simulation, p.p. 431-442, Greece 2007, ACM, ISBN:0302-9743.

[39] P. Levis,S. Madden,J. Polastre,R. Szewczyk,K. Whitehouse,A. Woo,D. Gay,J.

Hill,M. Welsh,E. Brewer,D. Culler.,TinyOS: An Operating System for Sensor Networks, Book: Ambient Intelligence, Springer 2005, ISBN: 978-3-540-27139-0

[40]TinyOS Programming Manual, Philip Levis, PDF accessed (27.07.2010) [http://csl.stanford.edu/~pal/pubs/tinyos-programming.pdf ]

[41] Samuel R. Madden,Michael J. Franklin, Joseph M. Hellerstein,Wei Hong, TinyDB: an acquisitional query processing system for sensor networks,

ACM Transactions on Database Systems Volume 30, p.p. 122-173, ACM March 2005, ISSN: 0362-5915.

[42] Teo A,Singh G.,McEachenJ.C.,Evaluation of the XMesh Routing Protocol in Wireless Sensor Networks,49th IEEE International Midwest Symposium on Circuits and Systems, 2006. MWSCAS '06. San Juan 6-9 Aug 2006, p.p. 1548-3746, IEEE 2007, ISBN: 1-4244-0172-0.

[43]XMesh User’s Manual, Revision D, April 2007, Crossbow Inc, PDF accessed (22.07.2010)

[http://www.memsic.com/support/documentation/wireless-sensor-networks/category/6-user-manuals.html?download=95%3Axmesh-user-s-manual]

[44] David Gay,Philip Levis,Robert von Behren,Matt Welsh,Eric Brewer,David Culler , The nesC language: A holistic approach to networked embedded systems,Proceedings of the ACM SIGPLAN 2003 conference on Programming language design and

implementation, San Diego USA 2003, p.p. 1-11, ACM 2003, ISBN:1-58113-662-5.

[45] Doug Simon, Cristina Cifuentes,The Squawk Virtual Machine: Java(TM) on the Bare Metal,Conference on Object Oriented Programming Systems Languages and Applications: Companion to the 20th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications,San Diego, CA, USA p.p. 150 - 151, ACM 2005, ISBN:1-59593-332-6.

[46]Connected Limited Device Configuration(CLDC); JSR 139, web page (accessed 19.08.2010) [http://java.sun.com/products/cldc/]

[47] The Squawk Project, web page (accessed 19.08.2010) [http://labs.oracle.com/projects/squawk/]

[48] Heinzelman, W.B, Murphy A.L.,Carvalho H.S.,Perillo M.A., Middleware to support sensor network applications, IEEE Network, p.p. 6-14, Jan/Feb 2004, IEEE Feb 2004, ISSN: 0890-8044

[49] Kay Römer,Oliver Kasten,Friedemann Mattern,Middleware challenges for wireless sensor networks,ACM SIGMOBILE Mobile Computing and Communications, Volume 6 October 2002, p.p. 59-61, ACM 2002, ISSN:1559-1662

[50] Jan New March,Jini 2 Programming, Apress Inc 2006, ‘Overview of Jini’, ISBN-10: 1-59059-716.8

[51] Yang Yu,Bhaskar Krishnamachari,Prasanna V.K., Issues in designing middleware for wireless sensor networks,IEEE Network, Jan/Feb 2004,Vol 18 ,p.p. 15 - 21,Los Angeles, USA, IEEE Feb 2004, ISSN: 0890-8044

[52] Hermann, C. Dargie, W. Tech. Univ. of Dresden,Senceive: A Middleware for a Wireless Sensor Network,Dresden, 22nd International Conference on Advanced

Information Networking and Applications AINA 2008, 25-28 March 2008, Okinawa, p.p.

612-619 IEEE 2008, ISBN: 978-0-7695-3095-6.

[53] Chien-Liang Fok,Gruia-Catalin Roman,Chenyang Lu,Agilla: A mobile agent middleware for self-adaptive wireless sensor networks,ACM Transactions on

Autonomous and Adaptive Systems (TAAS),Volume 4 2009,Article No:16, ACM 2009, ISSN:1556-4665.

[54] Aman Kansal,Suman Nath,Jie Liu,Feng Zhao, Microsoft Research,SenseWeb: An Infrastructure for Shared Sensing,IEEE Multimedia, Oct.-Dec. 2007,Vol 14, Issue:4 p.p. 8 - 13, IEEE 2007, ISSN:1070-986X .

[55] Mike Botts, George Percivall, Carl Reed and John Davidson,

OGC® Sensor Web Enablement: Overview and High Level Architecture,

GeoSensor Networks Second International Conference, GSN 2006, Boston, MA, USA, October 1-3, 2006 p.p. 72-86, Springer 2008, ISBN: 978-3-540-79995-5.

[56] McIlraith, S.A.,Son T.C.,Honglei Zeng, Knowledge Syst. Lab., Stanford Univ., CA, USA,Semantic Web services, IEEE Intelligent Systems, MarApr 2001,Vol 16 ,p.p. 46 -53, IEEE 2001, ISSN: 1541-1672.

[57] Nigel Shadbolt,Tim Berners-Lee,Wendy Hall,The Semantic Web Revisited, IEEE Intelligent Systems archive, Vol 21 May 2006, p.p. 96 - 101, ACM 2006, ISSN:

1541-1672.

[58]Swoolge ProjectHomePage, Web Page (accessed 19.08.2010), [http://pear.cs.umbc.edu/swoogle]

[59]Semantic Web Tools: An Overview, PDF (accessed 07.07.2010) [http://iam.inflibnet.ac.in:8080/dxml/handle/1944/1030]

[60] Li Ding, Pranam Kolari, Zhongli Ding, Sasikanth Avancha, Tim Finin, Anupam Joshi,University of Maryland Baltimore County Baltimore, Using Ontologies in the Semantic Web: A Survey, Ontologies A Handbook of Principles, Concepts and Applications in Information Systems,Springer 2007, ISBN: 978-0-387-37022-4.

[61] Fensel D.,van Harmelen, F.,Horrocks I.,McGuinness D.L.,Patel-Schneider P.F.,Vrije Univ.Amsterdam, Netherlands,OIL: an ontology infrastructure for the Semantic Web, IEEE Intelligent Systems, Mar-Apr 2001,Vol 16, p. 38 - 45 , IEEE 2001 , ISSN: 1541-1672.

[62] Xingchen Chu and Rajkumar Buyya,Service Oriented Sensor Web,Sensor Networks and Configuration 2007, Springer June 2007, ISBN: 978-3-540-37366-7.

[63] OGC, Sensor Model Language, web page (accessed 06.08.2010) [http://www.opengeospatial.org/standards/sensorml#overview]

[64] OGC, Introduction of SensorML, web page (accessed 06.08.2010) [ http://www.ogcnetwork.net/SensorML_Intro ].

[65] OGC, Sensor Web Enablement,web page (accessed 06.08.2010) [http://www.ogcnetwork.net/SWE ].

[66]Apache HTTP Server Project,web page (accessed 01.12.2009) [http://httpd.apache.org/download.cgi]

[67]JpGraph ,Graph Library for PHP, web page (accessed 25.12.2009) [http://jpgraph.net/]

[68]NuSOAP,PHP classes for Web Services, (accessed 04.01.2010) [http://www.scottnichol.com/nusoapintro.htm]

APPENDIX 1.

The code below shows the Gateway Application developed in by using J2SE for collecting sensor data and generating XML data.

/*

//drawgui();

JFrame fr= new JFrame("Communication Spot Free Range Sensor ");

status = new JTextArea();

+"Remote Sensor Reading"+"\n"+RawData);

* */

//changing the spot hardware address to store in database String nodea = "0014.4F01.0000.6D45";

String nodeb = "0014.4F01.0000.6A40";

/* splitted String RawData */

String readata = RawData;

String[] temp1; /* DataBase Connection and Insert */

System.out.println("Inserting values to Database");

Connection c= null;

c =

DriverManager.getConnection("jdbc:postgresql://localhost:5432/task", "postgres", "b0331969");

Statement select = c.createStatement();

int update = select.executeUpdate("INSERT INTO spot_result" + "(nodeid,xaxis,yaxis,zaxis,temp,light)" +

" VALUES(\'" + temp1[0] + "\',\'" + temp1[1] +

"\',\'" +

temp1[2] +"\',\'" +temp1[3]+ "\',\'" +temp1[4]+

"\'," +temp1[5]+ ")");

// System.out.println("Querying insert Error"); //debugging /* Reset the stream */

System.out.println ("No route to " + dgreply.getAddress());

}

finally {

org.sunspotworld.spotdata testa = new org.sunspotworld.spotdata();

org.sunspotworld.crossbowdata testb = new org.sunspotworld.crossbowdata();

testa.run();

testb.run();

} //finally } }

//Class to run the Crossbow Mote Xserve Application //Or either run that application manually from cygwin /**

public static void startxserve() throws Exception{

String path = ("C://Crossbow/cygwin/cygwin.bat");

try {

Runtime rt = Runtime.getRuntime();

Process pr = rt.exec(path);

}

catch (Exception e){

System.out.println(e.toString());

e.printStackTrace();}

} **/

/**

* Start up the host application.

*

* @param args any command line arguments */

public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException, Exception {

SunSpotHostApplication app = new SunSpotHostApplication();

app.run();

}

}

//END//

// CLASS spotdata to generate XML result from database.

System.out.println("Generating SunSpot XML-DATA of Sensors...");

Statement select = c.createStatement();

String sqlxmlquery = "select xmlelement(name Sensor,xmlelement(name NodeId, c.nodeid),"+

"xmlelement(name Xaxis, c.xaxis),xmlelement(name Yaxis, c.yaxis),"+

"xmlelement(name Zaxis, c.zaxis),xmlelement(name Temp, c.temp),"+

"xmlelement(name Light, c.light),"+

"xmlelement(name Time, c.modtime)) from spot_result c where nodeid='0014.4F01.0000.6A40';";

ResultSet result1 = select.executeQuery(sqlxmlquery);

//Debugging System.out.println(result1);

while (result1.next()) {

String outputsunspot= result1.getString(1);

System.out.println(outputsunspot);

File spot1 = new File("C:/Documents and

Settings/Admin/Desktop/webdump/xml_sensor_result/spotresult1.xml");

Writer writer = new BufferedWriter(new FileWriter(spot1));

writer.write(outputsunspot);

writer.close();

} //while

String spotquery2 = "select xmlelement(name Sensor,xmlelement(name NodeId, c.nodeid),"+

"xmlelement(name Xaxis, c.xaxis),xmlelement(name Yaxis, c.yaxis),"+

"xmlelement(name Zaxis, c.zaxis),xmlelement(name Temp, c.temp),"+

"xmlelement(name Light, c.light),"+

"xmlelement(name Time, c.modtime)) from spot_result c where nodeid='0014.4F01.0000.6D45';";

ResultSet result2 = select.executeQuery(spotquery2);

//Debugging System.out.println(result1);

while (result2.next()) {

String outputsunspot2= result2.getString(1);

System.out.println(outputsunspot2);

File spot2 = new File("C:/Documents and

Settings/Admin/Desktop/webdump/xml_sensor_result/spotresult2.xml");

Writer writer = new BufferedWriter(new FileWriter(spot2));

writer.write(outputsunspot2);

writer.close();

} //while

}

finally { } //finally }

}

//CLASS crossbowdata to generate XML data from database.

public void run() throws Exception{

try {

Class.forName("org.postgresql.Driver");

System.out.println("Generating CrossBowXML-DATA of Sensors...");

Connection c= null;

c =

DriverManager.getConnection("jdbc:postgresql://localhost:5432/task", "postgres", "b0331969");

Statement select = c.createStatement();

String crossbowquery1 = "select xmlelement(name Sensor,xmlelement(name NodeId, c.nodeid),"+

"xmlelement(name Xaxis, c.accel_x),xmlelement(name Yaxis, c.accel_y),"+

"xmlelement(name Humid, c.humid),"+

"xmlelement(name Temp, c.humtemp),"+

"xmlelement(name Time, c.result_time)) from mts400_results c where nodeid='1';";

ResultSet result1 = select.executeQuery(crossbowquery1);

//Debugging System.out.println(result1);

while (result1.next()) {

String outputcross1= result1.getString(1);

System.out.println(outputcross1);

File file1 = new File("C:/Documents and

Settings/Admin/Desktop/webdump/xml_sensor_result/crossbow_result1.xml")

;

Writer writer = new BufferedWriter(new FileWriter(file1));

writer.write(outputcross1);

writer.close();

} //while

String crossbowquery2 = "select xmlelement(name Sensor,xmlelement(name NodeId, c.nodeid),"+

"xmlelement(name Xaxis, c.accel_x),xmlelement(name Yaxis, c.accel_y),"+

"xmlelement(name Humid, c.humid),"+

"xmlelement(name Temp, c.humtemp),"+

"xmlelement(name Time, c.result_time)) from mts400_results c where nodeid='2';";

ResultSet result2 = select.executeQuery(crossbowquery2);

while (result2.next()) {

String outputcross2= result2.getString(1);

System.out.println(outputcross2);

File file2 = new File("C:/Documents and

Settings/Admin/Desktop/webdump/xml_sensor_result/crossbow_result2.xml")

;

Writer writer = new BufferedWriter(new FileWriter(file2));

writer.write(outputcross2);

writer.close();

} //while }

finally { } //finally }

}

APPENDIX. 2

Below code shows the web service developed in NuSOAP by using PHP.

<?php

//call library

require ("C:/php/nusoap/lib/nusoap.php");

// Instantiate a new soap server object

$server = new soap_server();

//Initiate WSDL Configuration

$server->configureWSDL('Sensorinfo','http://localhost/webservices');

//Desigate the WSDL namespace

$server->wsdl->schemaTargerNamespace = 'urn:Sensorinfo'; //

'http://localhost/Webservices'

// Function: getNodedata() // Inputs: None

// Outputs: A string containing information about a nodeid, // its temperature, and date.

$query = "SELECT * FROM spot_result WHERE nodeid='0014.4F01.0000.6A40' ORDER BY modtime DESC LIMIT 1";

$result = pg_query($query);

if (!$result) {

return new soap_fault('Server', '', 'Internal server error.');

}

$row = pg_fetch_array($result);

// Retrieve, assemble, and return the data

$query = "SELECT * FROM spot_result WHERE nodeid='0014.4F01.0000.6D45' ORDER BY modtime DESC LIMIT 1";

$result = pg_query($query);

if (!$result) {

return new soap_fault('Server', '', 'Internal server error.');

}

$row = pg_fetch_array($result);

// Retrieve, assemble, and return the data

$nodeid = $row["nodeid"];

$query = "SELECT * FROM mts400_results WHERE nodeid='1' ORDER BY result_time DESC LIMIT 1";

$result = pg_query($query);

if (!$result) {

return new soap_fault('Server', '', 'Internal server error.');

}

$row = pg_fetch_array($result);

// Retrieve, assemble, and return the data

$nodeid = $row["nodeid"];

$query = "SELECT * FROM mts400_results WHERE nodeid='2' ORDER BY result_time DESC LIMIT 1";

$result = pg_query($query);

if (!$result) {

return new soap_fault('Server', '', 'Internal server error.');

}

$row = pg_fetch_array($result);

// Retrieve, assemble, and return the data

$nodeid = $row["nodeid"];

}

// Register the getNodeData() method

$server->register("getNodedata", array('input' => 'xsd:string'), array('return' => 'xsd:string'), 'urn:Sensorinfo',

'urn:Sensorinfo#getNodedata' //,'rpc',

//'encoded','Return data to mobile client' );

// Automatically execute any incoming request

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA:

'';

$server->service($HTTP_RAW_POST_DATA);

?>