1 / 9

Web services in CS1/IS1

Web services in CS1/IS1 . 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.

avalon
Télécharger la présentation

Web services in CS1/IS1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web services in CS1/IS1

  2. 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. Don’t reinvent the wheels! Source: Savitch & Carrano 2009 CS1 text

  3. Description of class Scanner Package names Class names Software Reuse Source: Savitch & Carrano 2009 CS1 text

  4. 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. Software Reuse via SOA/WS • One popular way of implementing SOA is via Web services • WS (Web Service) • "a software system designed to support interoperablemachine-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 • 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. NetBeans Generated Code Template try { // Call Web Service Operation <someService> service = new <someService>; < someServicePort> port = service.get<someServicePort>(); // TODO initialize WS operation arguments here declarations of arguments here // TODO process result here <someResult> 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. 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. Repetition Structure mypackage.ISUDirectoryLookUpService service = new mypackage.ISUDirectoryLookUpService(); mypackage.ISUDirectoryLookUp port = service.getISUDirectoryLookUpPort(); // TODO initialize WS operation arguments here java.lang.StringlastName = aLastName; java.lang.StringfirstName = ""; 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. Repetition Structure (2) IntlistingSize = result.getItems().getDirectoryRecord().size(); for (inti = 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(); }

More Related