620 likes | 805 Views
Web Service. YU-RONG CHEN June 5 th 2014. Outline. Web Service SOAP WSDL UDDI Implementation RESTful Web Service REST Example Implementation Comparison. What is a Web Service?. “a method of communication between two electronic devices over the Web ” From Wiki
E N D
Web Service YU-RONG CHEN June 5th 2014
Outline • Web Service • SOAP • WSDL • UDDI • Implementation • RESTful Web Service • REST • Example • Implementation • Comparison
What is a Web Service? • “a method of communication between two electronic devices over the Web” • From Wiki • “a software system designed to support interoperable machine-to-machine interaction over a network” • From W3C (World Wide Web Consortium)
Why we use web services? • Interoperability • Web Services take Web-applications to the next level • Web Services have two types of uses • Reusable application-components • Connect existing software
Web Service Architecture Universal Description, Discovery and Integration Web Services Description Language Simple Object Access Protocol
SOAP • Simple Object Access Protocol • An XML based protocol for accessing Web Services. • Exchanges messages between different machines. • codifies the use of XML as an encoding scheme for request and response parameters using HTTP as a means for transport.
WSDL • Web Services Description Language • WSDL is an XML-based language for describing • what a service does • where it resides • how to invoke it • Characteristics of WSDL • Operations and messages are described abstractly • Defines bindings to message formats and protocols
WSDL document content • Abstract(interface) definition: • Concrete(implementation) definition
WSDL Example http://www.webservicex.net/globalweather.asmx?WSDL
Data that is sent Data that is returned
portType with operations Operations with request & response message
Bind an abstract operation to this implementation and map the abstract input and output messages to these concrete messages
Service name Network address of service
UDDI • Universal description, discovery, and integration • UDDI is a registry standard for Web service description and discovery together with a registry facility that supports the WS publishing and discovery processes. • UDDI enables a business to: • describe its business and its services • discover other businesses that offer desired services • integrate (interoperate) with these other businesses
UDDI(cont.) • Conceptually, a UDDI business registration consists of three inter-related components • “white pages” (address, contact, and other key points of contact) • “yellow pages” classification info. based on standard industry taxonomies • “green pages”, the technical capabilities and information about services
UDDI Data Structure • The UDDI XML schema defines 4core types of information • businessEntity: a description of the organization that provides the service. • businessService: a list of all the Web services offered by the business entity. • bindingTemplate: describes the technical aspects of the service being offered. • tModel: (“technical model”) is a generic element that can be used to store technical information on how to use the service, conditions for use, guarantees, etc.
How to implement Soap WS? • Two ways to implement: • Contract-First • encourages developers to think of the service contract first, in terms ofXML, using XML schema (.xsd) and WSDL • Contract-Last • expose an existing service interface as a web service • many tools and libraries can help expose a Java class/interface as a web service • define the contract for this web service as the laststep in the development process by generating it from Java code • Develop Contract-Last web Service • JAVA Service Programs Development • Web ServicesExposition Development • Web Services Client Development
Environment • JDK • jdk1.7.0_17 • Eclipse • Helios 7.1.1 • Tomcat • apache-tomcat-7.0.37
Programs Development (1/4) • Create Project • File New Dynamic Web Project
Programs Development (2/4) • Project Name • PurchaseOrder • Target runtime • Apache Tomcat
Programs Development (3/4) • Create a Class • Package ws.com • Class WebService_purchaseOrder
Programs Development (4/4) • Method • purchase_order_billTo Service functionality: Input two parameter: String Op1,int cash Output a String
Web services Development (1/5) • Create Web services • JavaFile Web Services Create Web Services
Web services Development (3/5) Methods
Web services Development (5/5) Generate wsdl
Web services Client Development (1/1) • New a Dynamic Web Project • New a Web Service Client
Web services Client Development (1/4) • Choose WSDL
Web services Client Development (2/4) • Use Test Client
Web services Client Development (3/4) • Choose output folder
Web services Client Development (4/4) • Client Testconfiguration setting
Criticisms • Too complex, not open source • A custom interface requires a custom client for every service • Concerns about performance due to XML and SOAP/HTTP in enveloping and transporting
REST(REpresentational State Transfer) • Introduced by Roy Fielding in his doctoral dissertation • He is one of the principal authors of the HTTP specification version 1.0 and 1.1 • Asoftware architectural style. • Interact with stateful resources, rather than messages or operations • Use HTTP standard operations such as GET, POST, PUT, DELETE
Noun(Resource) Representation(Content Type) Verb(method) Browser REST is kind of behavior to transfer the state of content type
REST Triangle (Resources)
Architectural Elements • Component • is an abstract unit of software instructions and internal state that provides a transformation of data via its interface • Connector • is an abstract mechanism that mediates communication, coordination, or cooperation among components • Data • is an element of information that is transferred from a component, or received by a component, via a connector
Architectural Constraints • Client-server • Stateless • Server contains no client state • Self-descriptive messages • Cacheable • Clients can cache responses • Layered system • Clients cannot tell whether it’s connected directly to the end server, or an intermediary • Code on demand (optional) • Servers can temporarily extend or customize the functionality of a client by the transfer of executable code. • Uniform interface