370 likes | 530 Views
Core Web Services Standards. (Simplified) Web Service Architecture. 1. Service Registers PUBLISH. 3. Client calls Service BIND. 2. Client Request Service Location FIND. Registry. Service Client. Web Service. SOAP (Simple Object Access Protocol). SOAP.
E N D
(Simplified) Web Service Architecture • 1. Service Registers • PUBLISH • 3. Client calls Service • BIND • 2. Client Request Service Location • FIND • Registry Service Client Web Service
SOAP (Simple Object Access Protocol)
SOAP Simple Object Access Protocol Wire protocol similar to IIOP for CORBA JRMP for RMI XML is used for data encoding “text” based protocol vs. “binary” protocol Supports XML-based RPC
What SOAP is Not Not a component model So it will not replace objects and components, i.e. EJB, JavaBeans Not a programming language So it will not replace Java Not a solution for all So it will not replace other distributed computing technologies such as RMI
What does SOAP Define? Message Envelope Encoding Rules RPC Convention Binding with underlying protocols
SOAP Message Format SOAP Message SOAP Envelope Primary MIME part (text/xml) SOAP Header Header Entry Header Entry Attachment SOAP Body Attachment Body Entry Body Entry Attachment
SOAP Message Envelope Encoding information Header Optional Could contain context knowledge Security Transaction Body RPC methods and parameters Contains application data
SOAP Encoding Rules of expressing application-defined data types in XML Based on W3C XML Schema Simple values Built-in types from XML Schema, Part 2 (simple types, enumerations, arrays of bytes) Compound values Structs, arrays, complex types
SOAP RPC Request Example <SOAP-ENV:Envelope xmlns:SOAP-ENV="…" SOAP-ENV:encodingStyle="…"> <SOAP-ENV:Header> <!-- Optional context information --> </SOAP-ENV:Header> <SOAP-ENV:Body><m:GetLastTradePrice xmlns:m=“some_URI"> <tickerSymbol>SUNW</tickerSymbol> </m:GetLastTradePrice></SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP RPC Response Example <SOAP-ENV:Envelopexmlns:SOAP-ENV="…" SOAP-ENV:encodingStyle="…"> <SOAP-ENV:Header> <!-- Optional context information --> </SOAP-ENV:Header> <SOAP-ENV:Body><m:GetLastTradePriceResponse xmlns:m=“some_URI"> <price>30.5</price> </m:GetLastTradePriceResponse></SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP RPC Information needed for a method call: The URI of the target object <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m=“http://stocks.com/StockQuotes"> <tickerSymbol>SUNW</tickerSymbol> </m:GetLastTradePrice> </SOAP-ENV:Body>
SOAP RPC Information needed for a method call: The URI of the target object Method name <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m=“http://stocks.com/StockQuotes"> <tickerSymbol>SUNW</tickerSymbol> </m:GetLastTradePrice> </SOAP-ENV:Body>
SOAP RPC Information needed for a method call: The URI of the target object Method name Parameters <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m=“http://stocks.com/StockQuotes"> <tickerSymbol>SUNW</tickerSymbol> </m:GetLastTradePrice> </SOAP-ENV:Body>
What is WSDL? XML language for describing web services Web service is described as A set of communication endpoints (ports) Endpoint is made of two parts Abstract definitions of operations and messages Concrete binding to networking protocol (and corresponding endpoint address) and message format Why this separation? Enhance reusability (as we will see in UDDI reference to WSDL document)
Why WSDL? Enables automation of communication details between communicating partners Machines can read WSDL Machines can invoke a service defined in WSDL Discoverable through registry Arbitration 3rd party can verify if communication conforms to WSDL
WSDL Document Example Simple service providing stock quotes A single operation called GetLastTradePrice Deployed using SOAP 1.1 over HTTP Request takes a ticker symbol of type string Response returns price as a float
Types Message Operation Port Type Binding Port Service WSDL Elements
WSDL Elements Types Data type definitions Used to describe exchanged messages Uses W3C XML Schema as canonical type system
WSDL Example: Types <definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/”> <types> <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2000/10/XMLSchema"> <element name="TradePriceRequest"> <complexType> <all> <element name=”tickerSymbol" type="string"/> </all> </complexType> </element> <element name="TradePrice"> <complexType> <all> <element name="price" type="float"/> </all> </complexType> </element> </schema> </types>
WSDL Elements Messages Abstract, typed definitions of data being exchanged Operations Abstract description of an action Refers to an input and/or output messages Port type Collection of operations Abstract definition of a service
Example: Messages, Operation, Port type <message name="GetLastTradePriceInput"> <part name="body" element="xsd1:TradePriceRequest"/> </message> <message name="GetLastTradePriceOutput"> <part name="body" element="xsd1:TradePrice"/> </message> <portType name="StockQuotePortType"> <operation name="GetLastTradePrice"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation> <!-- More operations --> </portType>
WSDL Elements Binding Concrete protocol and data format for a particular Port type Protocol example: SOAP 1.1 over HTTP or SOAP 1.1 over SMTP Port Defines a single communication endpoint Endpoint address for binding URL for HTTP, email address for SMTP Service Aggregate set of related ports
Example: Binding, Port, Service <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operationname="GetLastTradePrice"> <soap:operation soapAction="http://example.com/GetLastTradePrice"/> <input> <soap:body use="literal" /> </input> <output> <soap:body use="literal" /> </output> </operation> </binding> <service name="StockQuoteService"> <documentation>My first service</documentation> <port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location="http://example.com/stockquote"/> </port> </service>
Service Architecture • 1. Service Registers • PUBLISH • 3. Client calls Service • BIND • 2. Client Request Service Location • FIND • UDDI Registry Service Client Web Service UDDI defines a way to publish and find information about Web services.
UDDI (Universal Description, Discovery and Integration) “White pages” address, contact, and known identifiers “Yellow pages” industrial categorizations Industry: NAICS (Industry codes - US Govt.) Product/Services: UN/SPSC (ECMA) Location: Geographical taxonomy “Green pages” technical information about services
Other Web Services Standards
ebXML A global electronic market place where enterprises of any size, anywhere can: Find each other electronically Conduct business through exchange of XML based business messages
More Web Services Standards Security XML Signature, XML Encryption, XKMS, XACML, SAML, Liberty, WS-Security Transaction BTP, WS-Transaction Business collaboration and choreography ebXML BPSS, ebXML CPP/CPA, BPML, WSFL, XLANG, WSCI, BPEL4WS
More Web Services Standards Business Language UBL (Universal Business Language) Component model WSIA (Web Services for Interactive Application) Portal WSRP (Web Services for Remote Portals)
What Is a Web Service? A set of endpoints (ports) operating on messages Ports are operating within a container Container provides runtime environment Contract for runtime environment are specified in JAX-RPC, EJB 2.1, JSR 109 Service is described in WSDL document and published to a registry WSDL specifies a contract between service provider and client
Web Service Component and Container Container vs. Component model Web services components get executed within a container Components are portable (under J2EE 1.4) Web service components Web-tier (Servlet-based endpoint) EJB-tier (Stateless session bean-based endpoint)
Web Service Components Web services components Source: Web Services for J2EE (JSR 109), V1.0
Summary Web services provides a new paradigm for program to program communication Comprehensive set of Java APIs for Web Services are now available! J2EE is the platform of choice for Web services