720 likes | 1.13k Views
BP1070: Web Services – A Technical Overview. Ken Wilner (wilner@progress.com) Fellow. Agenda. Web Services Architecture Wire Stack Description Stack Discovery Stack That’s All Folks…. What Is a Web Service?.
E N D
BP1070:Web Services – A Technical Overview Ken Wilner (wilner@progress.com) Fellow
Agenda Web Services Architecture Wire Stack Description Stack Discovery Stack That’s All Folks…
What Is a Web Service? A Web Service is a software system identified by a URI, whose public interfaces and bindings are defined and described by XML. Its definition can be discovered by other software systems. These systems may then interact with the Web Service in a manner prescribed by its definition, using XML based messages conveyed by internet protocols. Web Services ArchitectureW3C Working Draft 14 November 2002http://www.w3.org/TR/ws-arch/ What the standards guys are saying.
What is a Web Service? An application that can be accessed over the Web or any network from another application using RPC style calls encoded using SOAP over HTTP where the interface is described using WSDL Ken Wilner, Fellow PSC Reality today.
Service-Oriented Architecture and Web Services Web ServiceRegistry Publish, Find, and Bind Find Web Service Publish Web Service ServiceDetails Interact (Bind) Web Service Provider Web ServiceRequestor
SOAP XML WSDL HTTP XML Schema Web Services Protocol Stacks Directory UDDI A Inspection Messaging Discovery Stack Data Encoding Network Protocol Service Orchestration Wire Stack Service Description Datatype Definition Description Stack
Web Services Implementation Architecture Web Server ApplicationServer POST(Soap) Web Service Client HTTP Listener SOAP Processor BusinessLogic Business Interface Response(Soap) WSDL Web Service
Web Server POST(Soap) Web Service Client HTTP Listener Web Services Adapter Response(Soap) AppServers WSDLFiles OpenEdge Web Services Toolkit Architecture
Why Should I Care? • Understand the standards that make up Web Services • Understand the state of Web Services and where its heading • Understand how to use Web Services efficiently • Understand why Web Services will be successful and where
SOAP XML HTTP Agenda Web Services Architecture Wire Stack Description Stack Discovery Stack That’s All Folks… Messaging Data Encoding Network Protocol Wire Stack
What It Is…. • A lightweight xml-based protocol for message exchange • Supports message typing, strong typing, and structured data • Can be used in a variety of communication paradigms • Programming language and platform independent • Highly extensible • Transport independent • Encoding independent • Extra context via headers
What It Is… • W3C Note SOAP V1.1 http://www.w3.org/TR/SOAP • SOAP message format • SOAP encoding • SOAP over HTTP transport binding • SOAP for RPC convention • W3C Draft SOAP V1.2 http://www.w3.org/TR/soap12-part0/ http://www.w3.org/TR/soap12-part1/ http://www.w3.org/TR/soap12-part2/
<Body> encloses body entries <Header> encloses headers (optional) Headers entries contain extensions Message name and data SOAP Header Header Entry … Header Entry SOAP Body Body Entry SOAP Message <Envelope> encloses message SOAP Envelope
SOAP Message <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Header> <hd:Security xmlns:hd="http://www.e1.com"> <username>Wilner</username> <password>BigDeal</password> </hd:Security> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:GetCustomer xmlns:ns1="http://www.e1.com"> <CustomerId xsi:type="xsd:int">6734</CustomerId> </ns1:GetCustomer> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP Envelope <SOAP-ENV:Envelope SOAP-ENV:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV= "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> … </SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP Body • Body entry contains application-specific data • Serialized based on encodingStyle • May represent an RPC request or response message, a specific document, or whatever you want
SOAP Body <SOAP-ENV:Envelope … > <SOAP-ENV:Body> <ns1:GetCustomer xmlns:ns1="http://www.e1.com"> <CustomerId xsi:type="xsd:int">6734</CustomerId> </ns1:GetCustomer> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP Header • Allows (optional) context information to be added to message independently of the payload • Authentication and authorization information • Transaction id • Object id • Intermediary specific information – chaining • Routing information – to, from, via, etc… • Security information • Auditing
SOAP Header <SOAP-ENV:Envelope … > <SOAP-ENV:Header> <hd:TID xmlns:hd="http://www.e1.com"> 673456:4439234:439439439349 </hd:TID> <hd:Securityxmlns:hd="http://www.e1.com"> <username>Wilner</username> <password>BigDeal</password> </hd:Security> </SOAP-ENV:Header> <SOAP-ENV:Body> … </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Transports • HTTP • SMTP (E-Mail) • FTP • Files • Postal Service • FAX • DOG
SOAP Over HTTP • As specified in SOAP V1.1 note • HTTP POST message • SOAPAction HTTP header • HTTP status code • 2xx indicates success • 500 indicates fault
HTTP Header SOAP Request SOAP Over HTTP Request • POST / HTTP/1.1 • SOAPAction: "http://www.e1.com/GetCustomer" • Content-Type: text/xml; charset=utf-8 • Host: localhost:8081 • Content-length: 706 • <SOAP-ENV:Envelope … > • <SOAP-ENV:Body> • <ns1:GetCustomer • xmlns:ns1="http://www.e1.com"> • <CustomerId xsi:type="xsd:int"> • 6734 • </CustomerId> • </ns1:GetCustomer> • </SOAP-ENV:Body> • </SOAP-ENV:Envelope>
HTTPResponseHeader SOAP Response SOAP Over HTTP Response • HTTP/1.1 200 OK • Content-Type: text/xml; charset=utf-8 • Content-Length: 226 • <SOAP-ENV:Envelope … > • <SOAP-ENV:Body> • <ns1:GetCustomerResponse xmlns:ns1="http://www.e1.com"> • <Name xsi:type="xsd:string"> • Fred Flintstone • </Name> • <Balance xsi:type="xsd:decimal"> • 2349.27 • </Balance> • </ns1:GetCustomerResponse> • </SOAP-ENV:Body> • </SOAP-ENV:Envelope>
Attachments • Standard way of attaching or including non-XML data in a Web Services (SOAP) request, e.g. a picture, an EXCEL file, another XML document, etc. • Two Approaches • SOAP with Attachments • based on MIME with extensions to SOAP and WSDL http://www.w3.org/TR/SOAP-attachments • WS-Attachments • A Microsoft and IBM proposal • based on DIME • A more efficient version of MIME http://www-106.ibm.com/developerworks/webservices/library/ws-attach.html
MIME Header SOAP Envelope MIME Part 0 SOAP Header SOAP Body MIME Part n SOAP with Attachments MIME Standard MIME header 1st MIME part containers SOAP message ... Other MIME parts container whatever you want ????????
SOAP with Attachments MIME-Version : 1.0 Content Type:Multipart/Related;boundary=MIME_boundary; type=text/xml; start=56987563343@progress.com--MIME_boundary Content-Type: text/xml; charset=UTF-8Content-Transfer-Encoding: 8bitContent-Id: <56987563343@progress.com><?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/> <SOAP-ENV:Body> <ns1:GetCustomerPictureResponse xmlns:ns1="http://www.e1.com"> <Picture href="cid:56987566734@progress.com" /> </ns1:GetCustomerPictureResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
SOAP with Attachments --MIME_boundary Content-Type: image/tiff Content-Transfer-Encoding: binary Content-Id: <56987566734@progress.com> …binary TIFF image --MIME_boundary
WSDL XML Schema Agenda Web Services Architecture Wire Stack Description Stack Discovery Stack That’s All Folks… Service Orchestration Service Description Datatype Definition Description Stack
WSDL Web Service Description Language W3C note – defacto standard http://www.w3.org/TR/WSDL.html • Service interface • What can it do? • Service implementation • How do I invoke it? • Service location (optional) • Where does it reside?
WSDL • Service interface maps to business interface • Generation approaches: • WSDL generated from business interface • Business interface generated from WSDL (industry standards)
XML Schema part XML Schema part XML Schema part XML Schema porttype binding binding ServiceInterface operation operation operation message message message WSDL types ServiceImplementation ServiceLocation service port
WSDL <definitions ….> <messages …> ... </messages> … <messages …> ... </messages> <portType …> … </portType> … <portType …> … </portType> <binding …> … </binding> <service…> … </service> </definitions>
WSDL Definitions <definitions name="CustomerAdmin" targetNamespace= "http://www.example.com/customer" xmlns:tns="http://www.example.com/customer" xmlns:soap= "http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"> xmlns="http://schemas.xmlsoap.org/wsdl/" … </definitions>
WSDL Messages <message name="GetCustomer"> <part name="CustomerId" type="xs:int"/> </message> <message name="GetCustomersResponse"> <part name="Name" type="xs:string"/> <part name="Balance" type="xs:decimal"/> </message>
WSDL PortType <portType name="CustomerPortType"> <operation name="GetCustomer"> <input message="tns:GetCustomer"/> <output message="tns:GetCustomerResponse"/> </operation> </portType>
WSDL Binding <binding name="CustomerBinding" type="tns:CustomerPortType"> <soap:binding style="rpc" transport= "http://schemas.xmlsoap.org/soap/http"/> <operation> … </operation> … </binding>
WSDL Binding <operation name="GetCustomer"> <soap:operationsoapAction= "http://www.progress.com/Sports"/> <input> <soap:body use="encoded“ encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.e1.com/customer"/> </input> <output> <soap:body use="encoded" encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.e1.com/customer"/> </output> </operation>
WSDL Service <service name="CustomerService"> <port name="CustomerPort" binding="CustomerBinding"> <soap:address location="http://www.example.com/customer"/> </port> </service>
WSDL Support for Attachments Binding <binding name="Customer_Binding" ... /> <soap:binding .../> <operation name="SetCustomerPicture"> <soap:operation ... /> <input> <mime:multipartRelated> <mime:part> <soap:body parts="CustomerId" use="encoded" ... /> </mime:part> <mime:part> <mime:content part="CustomerPicture" type="image/tiff"/> </mime:part> </mime:multipartRelated> </input> <output> … </output> </operation> </binding>
Service Orchestration • A fancy name for a business process • SOAP, WSDL, and "discovery mechanism" allow for loosely integrated Web Services • Business requirement to be able to model and formally describe complex Web Service interactions • Specifies the execution order of a collection of Web Services, e.g. • A travel reservation system • An mortgage application system
WebService WebService Business Process WebService WebService Service Orchestration WebServiceClient • Looks like a Web Service to the outside world • Accessed using WSDL • Needs to be flexible and adaptable • Swap out one service implementation for another • Requirement for a "process engine" that handles the flow between Web Services Web Service
Order Title Search • MortgageApp.wsdl • MortgageApp Porttype • SendMortgageRequest Operation Service Orchestration Mortgage Web Service Receive Mortgage Application Process Mortgage Order Appraisal Order Credit Check Process Application Notify Customer Web Service Invocation Message passing
Service Orchestration • Using standards allow process to be published, shared, and integrated with other processes • Lots of proposed standards – very immature • WSFL • http://www.ibm.com/software/solutions/webservices/pdf/WSFL.pdf • XLANG • http://msdn.microsoft.com/library/default.asp?url=/library/en-us/bts_2002/htm/bts_gs_content_rtzn.asp • BPML • http://www.bpmi.org • WSCI • http://www.w3.org/TR/wsci • BPEL4WS • http://www.ibm.com/developerworks/library/ws-bpel
BPEL4WS • Supercedes XLANG (Microsoft) and WSFL (IBM) • Subset of BPML • XML-based programming language for creating an executable business process • Message oriented • XML-oriented • Basic activities • Receive, reply, invoke • Assign and copy • Messages • Properties (variables) • Faults – throw/catch model
BPEL4WS • Structured activities • Sequences • Execute sequentially • Flows with links • Executes a set of activities in parallel with dependencies controlled by links • Wait • For time-out period • Until a specific date
BPEL4WS • Structured Activities • While • Execute an activity while a condition is true • Switch • Condition behavior based on an expression • Pick • Waits for an event and executes the corresponding activity • Two types of event • A particular message • A timeout
BPEL4WS • Scopes • A way of grouping a set of activities • Can be nested • Can bind a compensation handler to a scope for long running transaction support • Containers • Mechanism for holding messages and passing them from one step to the next
Other Web Services and clients by PortType partners containers faultHandlers <partner>….</partner>* <container>….</container>* <catch>….</catch>* Named storage for message Pointer to application data that correlates a async request with a reply, e.g. accountid correlationSets <correlationSet>….</correlationSet>* Alternate execution path when errors occur Code to execute when "undoing" a transaction compensationHandlers <compensationHandler>…. </compensationHandler>* What the process does. Typically, <sequence> or <flow> (Activity) BPEL4WS Document Structure Process
BPEL4WS <process name="purchaseOrderProcess" …> <partners> <partner name="Customer" serviceLinkType="lns:MortgageAppLT" myRole="MortgageService"/> <partner name="CreditCheckProvider" serviceLinkType="lns:CreditCheckLT" myRole="CreditCheckRequester" partnerRole="CreditCheckService"/> </partners> <containers> <container name="MortgageApp" messageType="lns:POMessage"/> </containers>
BPEL4WS <sequence> <receive partner="customer" portType="lns:MortgageAppPT" operation="sendMortgageApp" container="MortgageApp"> </receive> <invoke partner="CreditCheckProvider" portType="lns:computePricePT" operation="initiateCreditCheck" inputContainer="MortgageApp"> </sequence> </process>