On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai...

18
On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois State University Normal, IL 61790-5150, USA

Transcript of On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai...

Page 1: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

On Integrating Web Services From the Ground Up Into CS1/CS2

Billy B. L. LimChu JongPruthikrai Mahatanankoon

School of Information TechnologyIllinois State UniversityNormal, IL 61790-5150, USA

Page 2: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

Evolution of Approaches

Delivery mode Mainframe-based PCs

Text-based Graphical user interfaces (GUIs)

Web Applet

Next wave SOA (service-oriented architecture) / WS (Web

services)?

Page 3: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

Web services: The 4 W’s

What “A Web service is a software system designed to support

interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP-messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.” [W3C]

Web services Components WSDL (Web Service Description Language) SOAP (Simple Object Access Protocol) UDDI (Universal Description, Discovery, and Integration)

Why This seems to be one of the latest/greatest advances in software

development in recent years Interoperable, Easy to use, Reusable, Ubiquitous, Firewall-

friendly, Platform/language independent

Page 4: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

Web services: The 4 W’s

Who Major solution providers

Microsoft, IBM, Sun, Oracle, HP, BEA, etc. Consumers/Producers

State Farm, Caterpillar, Amazon, Google, Nordstrom, General Motors, Nasdaq, etc.

List of public Web Services http://www.xmethods.net/ Who should pay attention to this?

All of us! When

2006 to 2008 (fully dynamic search and use) [IDC] Casual / ad-hoc use of services New business models possible Commoditization of software Pervasive use in nontraditional devices

Page 5: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

Web services in CS1/CS2: Why?

Why not!

Page 6: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

Integration Scenarios

Method Invocation Sequential, Iterative, and Decision

Structures Sorting and/or Searching Miscellaneous Data structures Use of Different OS

Page 7: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

Sequential, Iterative, and Decision Structures

An example Traditional approach

Same old stuff Web services approach

A plausible scenario here is to discuss a problem where one wishes to find out the coldest temperature in an area by zip codes at a particular moment in time. Further, the coldest area needs to be plotted on a map.

Page 8: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

Sequential, Iterative, and Decision Structures (cont’d)

Web services available (for the task) http://www.xmethods.net/sd/2001/TemperatureS

ervice.wsdl Returns current temperature in a given U.S. zipcode

http://teachatechie.com/GJTTWebServices/ZipCode.asmx GetNearbyZipCodes

Returns a DataSet containing maximum of 250 zip codes and radius mileage within a given radius of a zip code

http://staging.mappoint.net/standard-30/mappoint.wsdl Finding Addresses, Finding Nearby Places, Routing,

Map Rendering, etc.

Page 9: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

WS-based Solution

Page 10: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

WS-based Solution

Page 11: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

WS-based Solution (C#)

// Get the two input valuesstring homeZip = textBox1.Text;string radius = textBox2.Text;ZipCode zipService = new ZipCode();

// get all the nearBy zipsDataSet ds =

zipService.GetNearbyZipCodes(homeZip,Convert.ToDecimal(radius));string[] zipArr = processZip(ds);

// get the coldest one and displaystring coldestZip = findColdestZip(zipArr);textBox3.Text = coldestZip;

// plot the map with the coldest zipgetMap(coldestZip);

Page 12: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

WS-based Solution (C#)

// Process the zipcodes (in XML format) and return them as an array of stringsstring[] processZip (DataSet ds) {

string xmlText = ds.GetXml();XmlDocument doc = new XmlDocument( );doc.LoadXml( xmlText);XmlNodeList zip = doc.GetElementsByTagName( "ZIP_CODE" );XmlNodeList distance = doc.GetElementsByTagName( "RADIUS_MILES" );

string[] zipArr = new string[zip.Count];for ( int i = 0; i < zip.Count; ++i ){

Console.WriteLine( "{0}, {1}", zip[i].InnerText, distance[i].InnerText);zipArr[i] = zip[i].InnerText;

}return zipArr;

}

Page 13: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

WS-based Solution (C#)// Iterate over all the zipcodes and find the temperature each time through. // Record the coldest one along the way.string findColdestZip(string [] zipArr) {

TemperatureService tempService = new TemperatureService();

// Get the first zipcodestring currentZip = zipArr[0];float coldestTemp = tempService.getTemp(currentZip);int coldestZip = 0;// Go thru all the other zipcodes and find the coldest temperaturefor (int i = 1; i < zipArr.Length; i++) {

currentZip = zipArr[i];float temp = tempService.getTemp(currentZip);if (temp < coldestTemp) {

coldestTemp = temp;coldestZip = i;

}}return zipArr[coldestZip];

}

Page 14: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

WS-based Solution (C#)void getMap(string coldestZip) {

string myUserId = “12345";string mySecurePassword = “secret";RenderServiceSoap renderService = new RenderServiceSoap();renderService.Credentials = new System.Net.NetworkCredential(myUserId, mySecurePassword);

FindServiceSoap findService = new FindServiceSoap();findService.Credentials = new System.Net.NetworkCredential(myUserId, mySecurePassword); FindSpecification findSpec = new FindSpecification();findSpec.DataSourceName = "MapPoint.NA";findSpec.InputPlace = coldestZip;

FindResults foundResults = findService.Find(findSpec);

ViewByHeightWidth[] myview = new ViewByHeightWidth[1];myview[0] = foundResults.Results[0].FoundLocation.BestMapView.ByHeightWidth;MapSpecification mapSpec = new MapSpecification();mapSpec.DataSourceName = "MapPoint.NA";mapSpec.Views = myview;mapSpec.Options = new MapOptions();mapSpec.Options.Format = new ImageFormat();mapSpec.Options.Format.Height = this.pictureBox1.Size.Height;mapSpec.Options.Format.Width = this.pictureBox1.Size.Width;

MapImage[] mapImages = renderService.GetMap(mapSpec);this.pictureBox1.Image =

Bitmap.FromStream(new System.IO.MemoryStream(mapImages[0].MimeData.Bits));}

Page 15: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

What to Put in / Take Out?

This will always be institution dependent! For us:

Put In: JUnit Testing, Web services Take Out: Some GUI, some Ethics

Perhaps in the near future, it will be easier to manage this In terms of approaches (e.g., how OOP replaces

structured programming) In terms of topics (e.g., how assembly

programming is no longer covered)

Page 16: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.

Concluding Remarks

Summary WS integration makes sense and doable! (but a

lot of work lie ahead) Please contribute (email me at [email protected])

and I’ll maintain the materials at: www.itk.ilstu.edu/lim/ws

Future Work More in-depth integration at my own School NSF grant application forthcoming

Stay tuned!

Page 17: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.
Page 18: On Integrating Web Services From the Ground Up Into CS1/CS2 Billy B. L. Lim Chu Jong Pruthikrai Mahatanankoon School of Information Technology Illinois.