1.09k likes | 1.28k Views
Web services @ work. Agenda. Everything about web services SOAP WSDL UDDI Questions Case Study. What are Web Services ?. Services offered over the network. Weather Service. Stock Quote Service. Inventory Information. Who should create web services?. Existing Computing Services
E N D
Agenda • Everything about web services • SOAP • WSDL • UDDI • Questions • Case Study
What are Web Services ? • Services offered over the network. Weather Service Stock Quote Service Inventory Information
Who should create web services? • Existing Computing Services • Existing Data storage Services • Existing Search Services • Existing Informational Services • And….. • Everybody who want to leverage existing functionality and offer the same to whole world.
Enabling existing services Clients Internet HTTP Server (Apache, Tomcat, IIS) SMTP Server Agents Application Server (Axis) Engine (Axis) ServiceWrapper New ServiceImplementation Legacy System
Who consumes web services ? • Integrators • Support utilities • CRM Software
How to create web service • Be Guided by following standards • XML • SOAP • UDDI • HTTP (or any standard protocol) You can turn any existing functionality into web service, by adhering to above standards
Web services related Standards • SOAP 1.2 • UDDI 1.3 • WSDL 1.2 • HTTP 1.1 • These are set by standards body like W3C,OASIS.
Major development platforms • Microsoft’s .NET • Sun’s Web Services API • IBM’s Websphere
When not to use web services • Performance requirements • Security and reliability • No reuse requirements • Lack of Web services support • Organizational or technical alignment
Goal • Access objects and services on remote servers in platform independent manner
AGENDA • What is SOAP • What is NOT SOAP • Why SOAP • SOAP Message Details
Web Services Technologies UDDI Registry WSDL Points to description Points to service Describes Service Finds Service Service Consumer Web Service SOAP Communicates with XML Messages
What is SOAP • Simple Object Access Protocol • Lightweight protocol for exchanging structural information • Uses XML Technologies • Independent of any platform/technology • Simple and Extensible
What is NOT SOAP • A full-fledged distributed object system with support for • Objects-by-reference • Activation • Message batching • Distributed garbage collection • Naming and directory services • SOAP sacrifices these features for platform-neutrality and extensibility
Typical SOAP message • <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" > • <soap:Header> • <!-- header element(s) here --> • </soap:Header> • <soap:Body> • <!-- body element(s) here --> • </soap:Body> • </soap:Envelope>
Example SOAP Message • <?xml version="1.0" encoding="UTF-8"?> • <SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" • xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" • xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> • <SOAP-ENV:Body> • <ns1:echoString xmlns:ns1="http://soapinterop.org/"> • <testParam xsi:type="xsd:string">Hello!</testParam> • </ns1:echoString> • </SOAP-ENV:Body> • </SOAP-ENV:Envelope>
SOAP Messaging Model Communication protocol SOAP Sender SOAP Receiver Envelope SOAP Message xml
Typical soap request over HTTP POST /StockQuote HTTP/1.1 Host: www.stockquoteserver.com Content-Type: text/xml; charset="utf-8" Content-Length: nnnn SOAPAction: "Some-URI" <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m="Some-URI"> <symbol>DIS</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Typical soap response over HTTP HTTP/1.1 200 OK Content-Type: text/xml; charset="utf-8" Content-Length: nnnn <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> <SOAP-ENV:Body> <m:GetLastTradePriceResponse xmlns:m="Some-URI"> <Price>34.5</Price> </m:GetLastTradePriceResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP Players Initial SOAPSender SOAP Intermediary SOAP Intermediary Ultimate SOAPReceiver SMTP MSMQ HTTP SOAP Message Path
RPC and Document Styles Document RPC • Procedure Call • Synchronous • Marshalling and Unmarshalling parameters between Java Objects and XML • For simple point to point sync call Document-driven Asynchronous and synchronous Used when data is large and fluid
RPC Style SOAP Message • <soapenv:Envelopexmlns:soapenv="soap_ns"xmlns:xsd="xml_schema_ns"xmlns:xsi="type_ns"><soapenv:Body> <ns1:getStockPrice xmlns:ns1="app_ns" soapenv:encodingStyle="encoding_ns"> <stockSymbol xsi:type="xsd:string"> • AAPL • </stockSymbol> </ns1:getStockPrice></soapenv:Body></soapenv:Envelope>
Document Style SOAP Message • <soapenv:Envelopexmlns:soapenv="soap_ns"xmlns:xsd="xml_schema_ns"xmlns:xsi="type_ns"><soapenv:Body><ns1:customerOrdersoapenv:encodingStyle="encoding_ns"xmlns:ns1="app_ns"><order> <customer> <name>Plastic Pens, Inc.</name> <address> <street>123 Yukon Drive</street> <city>Phoenix</city> <state>AZ</state> <zip>85021</zip> </address> </customer> <orderInfo> <item> <partNumber>563</partNumber> <description>Red stappler</description> <quantity>30</quantity> <item> </orderInfo></order></ns1:customerOrder></soapenv:Body></soapenv:Envelope>
Processing SOAP Message • SOAP HEADER Block and Node • Supports Multiple Message Exchange Patterns • One Way • Request/Response • Peer to Peer • Each Message is independently Processed • Roles for Node • next • none • ultimatereceiver
What happens when message arrives • Node determines set of roles in which it needs to act on message • Identify all the header blocks targeted for the Node • If header block is not understood, generate fault and no further processing is done. • Process mandatory SOAP HEADER block • Process BODY if Node is ultimate receiver • Relay message if Node is playing intermediary role.
SOAP Extensibility • SOAP Processing Model • SOAP Binding Framework • Formal set of rules for carrying soap message over underlying protocol. • HTTP Binding
SOAP EncodingStyle • http://www.w3.org/2001/12/soap-encoding • To define data types used in the document <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> ... Message information goes here ... </soap:Envelope>
SOAP RPC Representation • Method Invocation modeled as single struct • Struct is name identical to method • Parameter has the same name and order • Method Response is also modeled as struct
Supported String int/Integer decimal float/Float double/Double date boolean/Boolean Long/Long Short/Short Byte/Byte hex Not Supported BigDecimal Other ? Data Types
Where can FAULT Occur • Client • Server • Protocol
Example FAULT Message in HTTP • HTTP/1.1 500 Internal Server Error • Content-Type: text/xml; charset="utf-8" • Content-Length: nnnn • <SOAP-ENV:Envelope • xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> • <SOAP-ENV:Body> • <SOAP-ENV:Fault> • <faultcode>SOAP-ENV:Server</faultcode> • <faultstring>Server Error</faultstring> • <detail> • <e:myfaultdetails xmlns:e="Some-URI"> • <message> • My application didn't work • </message> • <errorcode> • 1001 • </errorcode> • </e:myfaultdetails> • </detail> • </SOAP-ENV:Fault> • </SOAP-ENV:Body> • </SOAP-ENV:Envelope>
Basic Web Services use SOAP Brokerage Application Accounting Application Trader Application Buy 500 shares MSFT @$40/share ID=Bob Debit $20000 ID=Bob SOAP Sender SOAP Receiver/ Sender SOAP Receiver Confirm Debit $20000 Bought 500 shares MSFT @$40/share
SOAP-interoperability • Following things must happen • The ability for the server to parse the client's SOAP envelope. • The ability for the server to deserialize the encoded parameter contained within the envelope • The ability for the client to parse the SOAP envelope sent by the server in response • The ability for the client to deserialize the encoded parameter sent back from the server. • Main concerns • SOAP Specification follow up • Data type • Precision support for float/decimal, date time, Arrays
Food for thought • Scenario where soap intermediary is needed • How much payload of minimal SOAP Packet. • Do you really need SOAP for web services? • SOAP Over JMS? • SOAP and Performance? • SOAP slower than XML-RPC by almost 8 times !!
References • http://www.w3.org/TR/SOAP/ • http://msdn.microsoft.com/library/ • http://www.soapuser.com • http://xml.apache.org/soap/ • http://www.xmethods.com
What Next • WS-Security • WS-Policy • WS-Trust • WS-Federation • …….
WSDL Web Services Description Language
Agenda • What is WSDL • Why WSDL • WSDL Structure • Usage • Consumers of WSDL • Questions
Your business for others… • You need grammar to describe what your business do. Grammar should address .. • What services are offered by you • How can others invoke a service • What information your service needs • How user will provide information • What information you can provide • What format you expect WSDL is the answer