Download presentation
Presentation is loading. Please wait.
Published byGarey Flynn Modified over 9 years ago
1
Web services in CS1/IS1
2
School of Information Technology Reusable Components Most programs are created by combining components that exist already, not from scratch! Reusing components saves time and money. Reused components are likely to be better developed, and more reliable. New components should designed to be reusable by other applications. Source: Savitch & Carrano 2009 CS1 text
3
School of Information Technology Software Reuse Package names Class names Description of class Scanner Source: Savitch & Carrano 2009 CS1 text
4
School of Information Technology Software Reuse via SOA/WS Latest form of reuse is via “services” SOA (Service-Oriented Architecture) – “A system for linking resources on demand. In an SOA, resources are made available to other participants in the network as independent services that are accessed in a standardized way. This provides for more flexible loose coupling of resources than in traditional systems architectures.” –Sybase – “Architecture that describes an entity (e.g., application or enterprise) as a set of interdependent services. SOA provides for reuse of existing services and the rapid deployment of new business capabilities based on existing assets.” -- CIO.gov – Many others …
5
School of Information Technology Software Reuse via SOA/WS One popular way of implementing SOA is via Web services WS (Web Service) – "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.“ – W3Cinteroperablemachine-to- machinenetworkWSDL – Laymen terms: a piece of program that can interact with another program using standardized Web protocols – Examples: Google Maps API, Flickr API, Twitter API, Amazon Web services. (API = Application Programming Interface)
6
School of Information Technology NetBeans Generated Code Template try { // Call Web Service Operation service = new ; port = service.get (); // TODO initialize WS operation arguments here declarations of arguments here // TODO process result here result = port.methodOfInterest(argument list); System.out.println("Result = "+result); } catch (Exception ex) { // TODO handle custom exceptions here } Bold: Statements of interests; Wish Exception ex was printed as part of the template.
7
School of Information Technology Decision Structure try { // Call Web Service Operation com.cdyne.ws.profanityws.profanity.Profanity service = new com.cdyne.ws.profanityws.profanity.Profanity(); com.cdyne.ws.profanityws.profanity.ProfanitySoap port = service.getProfanitySoap(); // TODO initialize WS operation arguments here java.lang.String text = “You smoked weed? Dumb!"; // TODO process result here com.cdyne.ws.profanityws.profanity.FilterReturn result = port.simpleProfanityFilter(text); if (result.isFoundProfanity()) … else … } catch (Exception ex) { // TODO handle custom exceptions here }
8
School of Information Technology Repetition Structure mypackage.ISUDirectoryLookUpService service = new mypackage.ISUDirectoryLookUpService(); mypackage.ISUDirectoryLookUp port = service.getISUDirectoryLookUpPort(); // TODO initialize WS operation arguments here java.lang.String lastName = aLastName; java.lang.String firstName = ""; java.lang.String city = ""; java.lang.String state = ""; java.lang.String zip = ""; // TODO process result here mypackage.DirectoryResult result = port.findPerson(lastName, firstName, city, state, zip);
9
School of Information Technology Repetition Structure (2) Int listingSize = result.getItems().getDirectoryRecord().size(); for (int i = 0; i < listingSize; i++) { firstName = result.getItems().getDirectoryRecord().get(i).getFirstName(); lastName = result.getItems().getDirectoryRecord().get(i).getLastName(); zip = result.getItems().getDirectoryRecord().get(i).getZip(); phone = result.getItems().getDirectoryRecord().get(i).getPhone(); state = result.getItems().getDirectoryRecord().get(i).getState(); cityNamePrint = result.getItems().getDirectoryRecord().get(i).getCity(); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.