38
Introduction to SOAP, WSDL & Web Services Enterprise Application Development (EAD)

EAD Lecture 5 - Introduction to SOAP,WSDL & Web Services (1)

Embed Size (px)

DESCRIPTION

nnnnnnnnnnnn

Citation preview

  • Introduction to SOAP, WSDL & Web ServicesEnterprise Application Development (EAD)

    Introduction to SOAP,WSDL & Web Services

    AgendaWhat is SOAP?Why SOAP?How SOAP works?Structure of the SOAP MessageSOAP Header/SOAP BodyMapping SOAP to a Transport Protocol (HTTP)Introduction to WSDL WSDL Document StructureWSDL TypesWSDL MessagesWSDL PortsWSDL BindingsIntroduction to Web Services

    Introduction to SOAP,WSDL & Web Services

    ReferencesWeb Services Description and SOAP Messages by Richard Hopkins, National e-Science Centre, Edinburgh.

    SOA using OpenESB, BPEL, and NetBeans by Sang ShinJava Technology Evangelist Sun Microsystems, Inc.

    SOAP II: Data Encoding by Marlon Pierce, Bryan Carpenter, Geoffrey Fox Community Grids Lab, Indiana University.

    Introduction to Web Services Simple Object Access Protocol (SOAP) Gustavo Alonso and Cesare Pautasso, Computer Science Department Swiss Federal Institute of Technology (ETHZ)

    http://www.w3schools.com/

    Introduction to SOAP,WSDL & Web Services

    Why SOAP?RPC is an obvious and popular paradigm for implementing the client-server model of distributed computing.

    Different RPC protocols exist today.Sun RPC, DCE/RPC, DCOM, CORBA

    Most of the RPC protocols are too low level and certainly not compatible among each other (gateways are needed)

    Since RPC represents a compatibility and security problems, firewalls and proxy servers will normally block this kind of traffic.

    To address this problem, XML was used to define SOAP.

    Soap uses HTTP/SMTP as the communication protocol

    Introduction to SOAP,WSDL & Web Services

    What is SOAP?XML-based protocol for exchanging information between applications.

    Primary focus of SOAP is Remote Procedure Calls transported via HTTP.

    Similar to DCOM, CORBA, and Java RMI, the main difference is that SOAP messages are written entirely in XML.

    SOAP is therefore uniquely platform and language independent.

    For example, a SOAP Java client running on Linux or a Perl client running on Solaris can connect to a Microsoft SOAP server running on Windows 2000.

    Introduction to SOAP,WSDL & Web Services

    How SOAP works?RPC Using HTTP

    At the Client Turns the RPC call into a XML document

    Transports the XML data over HTTP (or SMTP) (Client to Server)

    At the Server Turns the XML document into a procedure callTurns the procedures response into a XML document

    Transports the XML data over HTTP (or SMTP) (Server to Client)

    At the ClientTurns the XML data into the response to the RPC

    Introduction to SOAP,WSDL & Web Services

    Structure of a SOAP MessageSOAP is based on message exchanges.

    Messages are seen as envelopes where the application encloses the data to be sent.

    A message has two main parts; header and body, which both can be divided into blocks.

    SOAP does not specify what to do in the body, it only states that the header is optional and the body is mandatory.

    The use of header and body, however, is implicit. The body is for application level data. The header is for infrastructure level data.

    Introduction to SOAP,WSDL & Web Services

    SOAP Message

    Introduction to SOAP,WSDL & Web Services

    SOAP HeaderThe header is intended as a generic place holder for information that is not necessarily application dependent (the application may not even be aware that a header was attached to the message).

    Typical uses of the header are: coordination information, identifiers (for, e.g.: transactions) and security information (e.g.: certificates)

    Introduction to SOAP,WSDL & Web Services

    SOAP BodyThe body is intended for the application specific data contained in the message.Also it may contain a Fault entry Section (for reporting errors in processing a SOAP message)

    Introduction to SOAP,WSDL & Web Services

    Mapping SOAP to a Transport Protocol (HTTP)

    Introduction to SOAP,WSDL & Web Services

    HTTP as Communication Protocol

    Introduction to SOAP,WSDL & Web Services

    HTTP Server Side

    Introduction to SOAP,WSDL & Web Services

    Parameter Passing

    Introduction to SOAP,WSDL & Web Services

    SOAP and HTTP

    Introduction to SOAP,WSDL & Web Services

    HTTP Request

    Introduction to SOAP,WSDL & Web Services

    HTTP Response

    Introduction to SOAP,WSDL & Web Services

    Introduction to WSDL

    Introduction to SOAP,WSDL & Web Services

    What is WSDL?WSDL stands for Web Services Description Language WSDL is as XML document

    WSDL is used to describe Web services It specifies the location of the service and the operations (or methods) the service exposes

    WSDL is also used to locate Web services

    Introduction to SOAP,WSDL & Web Services

    The WSDL Document Structure A WSDL document describes a web service using these major elements:

    - The data types used by the web service - The messages used by the web service - The operations exposed by the web service - The communication protocols used by the web service

    Introduction to SOAP,WSDL & Web Services

    WSDL Types The element defines the data types that are used by the web service.

    For maximum platform neutrality, WSDL uses XML Schema syntax to define data types.

    Introduction to SOAP,WSDL & Web Services

    WSDL Messages The element defines the data elements of an operation.

    Each message can consist of one or more parts. The parts can be compared to the parameters of a function call in a traditional programming language.

    Introduction to SOAP,WSDL & Web Services

    WSDL PortA WSDL port describes the interfaces (legal operations) exposed by a web service.

    It defines a web service, the operations that can be performed, and the messages that are involved.

    Operation Types One-way Request-response Solicit-response Notification

    Introduction to SOAP,WSDL & Web Services

    One-Way Operation

    Introduction to SOAP,WSDL & Web Services

    Request-Response Operation

  • End

    IFS Training IFS Applications 2003

    IFS Training IFS Applications 2003

    IFS Training IFS Applications 2003

    IFS Training IFS Applications 2003

    In computer science, a remote procedure call (RPC) is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction. That is, the programmer writes essentially the same code whether the subroutine is local to the executing program, or remote. When the software in question uses object-oriented principles, RPC is called remote invocation or remote method invocation.

    SOAP is a simple XML-based protocol to let applications exchange information over HTTP.Or more simply: SOAP is a protocol for accessing a Web Service.

    IFS Training IFS Applications 2003

    Notice the xmlns:soap namespace in the example above. It should always have the value of: "http://www.w3.org/2001/12/soap-envelope".The namespace defines the Envelope as a SOAP Envelope.If a different namespace is used, the application generates an error and discards the message.

    The encodingStyle attribute is used to define the data types used in the document. This attribute may appear on any SOAP element, and applies to the element's contents and all child elements.A SOAP message has no default encoding.

    The SOAP mustUnderstand attribute can be used to indicate whether a header entry is mandatory or optional for the recipient to process.If you add mustUnderstand="1" to a child element of the Header element it indicates that the receiver processing the Header must recognize the element. If the receiver does not recognize the element it will fail when processing the Header.

    This attribute is used to ensure that SOAP nodes do not ignore header blocks which are important to the overall purpose of the application. If a SOAP node determines (using the role or actor attribute) that it should process a header block, and the mustUnderstand attribute has a value of "true", then the node must either process the header block in a manner consistent with its specification, or not at all (and throw a fault). But if the attribute has a value of "false", the node is not obliged to process the header block.In effect, the mustUnderstand attribute indicates whether processing of the header block is mandatory or optional.

    IFS Training IFS Applications 2003

    234 ... ... IFS Training IFS Applications 2003

    The SOAPelement is used to carry error and status information within a SOAP message.If present, the SOAPelement must appear as a body entry and must not appear more than once within a Body element. The subelements of the SOAPelement are different in SOAP 1.1 and SOAP 1.2.

    IFS Training IFS Applications 2003

    Multipurpose Internet Mail Extensions is an Internet standard

    An Internet media type is a standard identifier used on the Internet to indicate the type of data that a file contains. Common uses include the following:

    email clients use them to identify attachment files,web browsers use them to determine how to display or output files that are not in HTML format,search engines use them to classify data files on the web.IFS Training IFS Applications 2003

    "CGI" stands for "Common Gateway Interface." CGI is one method by which a web server can obtain data from (or send data to) databases, documents, and other programs, and present that data to viewers via the web. More simply, a CGI is a program intended to be run on the web. A CGI program can be written in any programming language, but Perl is one of the most popular,IFS Training IFS Applications 2003

    A WSDL document is just a simple XML document.It contains set of definitions to describe a web service.IFS Training IFS Applications 2003

    A WSDL document can also contain other elements, like extension elements, and a service element that makes it possible to group together the definitions of several web services in one single WSDL document.

    IFS Training IFS Applications 2003

    xmlns:s="http://www.w3.org/2001/XMLSchema"

    IFS Training IFS Applications 2003

    The element is the most important WSDL element.

    It describes a web service, the operations that can be performed, and the messages that are involved.

    The element can be compared to a function library (or a module, or a class) in a traditional programming language.

    IFS Training IFS Applications 2003

    IFS Training IFS Applications 2003

    In this example the element defines "glossaryTerms" as the name of a port, and "getTerm" as the name of an operation.The "getTerm" operation has an input message called "getTermRequest" and an output message called "getTermResponse".The elements define the parts of each message and the associated data types.

    Compared to traditional programming, glossaryTerms is a function library, "getTerm" is a function with "getTermRequest" as the input parameter, and getTermResponse as the return parameter.IFS Training IFS Applications 2003

    When you create a WSDL binding that maps a portType's operations to SOAP messages sent over HTTP, you have to specify whether the SOAP messages contain literal or encoded instances of the schema constructs the operations use. If you choose "literal," you are saying that the XML Schema constructs your WSDL definitions refer to are concrete specifications of what will appear in your SOAP message bodies. If you choose "encoded," you are saying that the XML Schema constructs your WSDL definitions refer to are abstract specifications of what will appear in your SOAP message bodies; these can be made concrete by applying the rules defined by SOAP encoding. (The WSDL specification allows other encoding schemes as well, but alternatives are rarely if ever used.)

    Theelement provides specific details on how aportTypeoperation will actually be transmitted over the wire.The bindings can be made available via multiple transports, including HTTP GET, HTTP POST, or SOAP.The bindings provide concrete information on what protocol is being used to transferportTypeoperations.The bindings provide information where the service is located.For SOAP protocol, the binding is, and the transport is SOAP messages on top of HTTP protocol.You can specify multiple bindings for a singleportType.

    Thesoap:bindingelement has two attributes - style and transport.The style attribute can be "rpc" or "document". The transport attribute defines the SOAP protocol to use. In this case we use HTTP.

    IFS Training IFS Applications 2003

    Universal Description, Discovery and Integration (UDDI)IFS Training IFS Applications 2003

    orchestrating - arranging, organizing, coordianating

    IFS Training IFS Applications 2003

    IFS Training IFS Applications 2003