web services darshan r. kapadia gregor von laszewski 1

25
Web Services Darshan R. Kapadia Gregor von Laszewski 1 http://grid.rit.edu

Upload: wesley-friend

Post on 14-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

http://grid.rit.edu 1

Web Services

Darshan R. KapadiaGregor von Laszewski

http://grid.rit.edu 2

What are Web Services?

• A Web service (also Web Service) is defined by the W3C as "a software system designed to support interoperable machine-to-machine interaction over a network".

• Web Services can convert your application into a Web-application, which can publish its function or message to the rest of the world.

http://en.wikipedia.org/wiki/Web_service

http://grid.rit.edu 3

What are Web Services?

• Web services are application components• Web services communicate using open

protocols• Web services are self-contained and self-

describing• Web services can be discovered using

UDDI(Universal Description, Discovery and Integration)

• Web services can be used by other applications• XML is the basis for Web services

http://grid.rit.edu 4

Interoperability has Highest Priority!!

• When all major platforms could access the Web using Web browsers, different platforms could interact. For these platforms to work together, Web-applications were developed.

• Web-applications are simple applications that run on the web. These are built around the Web browser standards and can be used by any browser on any platform.

• By using Web services, your application can publish its function or message to the rest of the world.

• Web services use XML to code and to decode data, and SOAP to transport it (using open protocols).

http://grid.rit.edu 5

Elements of Web Services

• The basic Web services platform is XML + HTTP.• XML provides a language which can be used

between different platforms and programming languages and still express complex messages and functions.

• The HTTP protocol is the most used Internet protocol.

• Web services platform elements:– SOAP (Simple Object Access Protocol)– UDDI (Universal Description, Discovery and Integration)– WSDL (Web Services Description Language)

What is SOAP?

• SOAP stands for Simple Object Access Protocol• SOAP is an XML-based protocol to let applications exchange

information over HTTP.• SOAP is a protocol for accessing a Web Service.• SOAP is a communication protocol• SOAP is a format for sending messages• SOAP is designed to communicate via Internet • SOAP is platform independent• SOAP is language independent• SOAP is based on XML

http://grid.rit.edu 7

What is WSDL?

• WSDL stands for Web Services Description Language

• WSDL is an XML-based language for locating and describing Web services.

• WSDL is based on XML • WSDL is used to describe Web services• WSDL is used to locate Web services

What is UDDI?

• UDDI stands for Universal Description, Discovery and Integration

• UDDI is a directory service where companies can register and search for Web services.

• UDDI is a directory for storing information about web services

• UDDI is a directory of web service interfaces described by WSDL

• UDDI communicates via SOAP• UDDI is built into the Microsoft .NET platform

Example of Web Service

http://grid.rit.edu 10

WHY SOAP?

• Today's applications communicate using Remote Procedure Calls (RPC) between objects like DCOM and CORBA, but HTTP was not designed for this. RPC represents a compatibility and security problem; firewalls and proxy servers will normally block this kind of traffic.

• A better way to communicate between applications is over HTTP, because HTTP is supported by all Internet browsers and servers. SOAP was created to accomplish this.

• SOAP provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.

SOAP Building Blocks

• A SOAP message is an ordinary XML document containing the following elements:– An Envelope element that identifies the XML

document as a SOAP message– A Header element that contains header

information– A Body element that contains call and response

information– A Fault element containing errors and status

information

Skeleton SOAP Message

<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>...</soap:Header>

<soap:Body>... <soap:Fault> ... </soap:Fault></soap:Body>

</soap:Envelope>

http://grid.rit.edu 13

The SOAP Envelope Element

• The SOAP Envelope element is the root element of a SOAP message.

• The required SOAP Envelope element is the root element of a SOAP message. This element defines the XML document as a SOAP message.

<?xml version="1.0"?><soap:Envelopexmlns: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>

http://grid.rit.edu 14

The SOAP Header Element

• The SOAP Header element contains header information.

• The optional SOAP Header element contains application-specific information (like authentication, payment, etc) about the SOAP message.

• If the Header element is present, it must be the first child element of the Envelope element.

The SOAP Body Element

• The required SOAP Body element contains the actual SOAP message intended for the ultimate endpoint of the message.

<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body> <m:GetPrice xmlns:m="http://www.w3schools.com/prices"> <m:Item>Apples</m:Item> </m:GetPrice></soap:Body>

</soap:Envelope>

Andrew F Fitzgerald
Perhaps Aric and I should work together on this?http://gdp.globs.org/gt4-tutorial/multiplehtml/ch10s05.html has some nice diagrams that describe 1) the problem and 2) how certificates work with this

http://grid.rit.edu 16

The SOAP Fault Element

• The SOAP Fault element hold errors and status information for a SOAP message.

• The optional SOAP Fault element is used to indicate error messages.

• If a Fault element is present, it must appear as a child element of the Body element.

• A Fault element can only appear once in a SOAP message.

http://grid.rit.edu 17

The SOAP Fault Element-Sub Elements

Sub Element Description <faultcode> A code for identifying the fault<faultstring> A human readable explanation of

the fault <faultfactor> Information about who caused the

fault to happen <detail> Holds application specific error

information related to the Body element

Example of SOAP

http://grid.rit.edu 19

WSDL

• WSDL stands for Web Services Description Language.

• WSDL is an XML-based language for describing Web services and how to access them.

• WSDL is a document written in XML. The document describes a Web service. It specifies the location of the service and the operations (or methods) the service exposes.

http://grid.rit.edu 20

WSDL Document• <definitions>

<types> definition of types........</types>

<message> definition of a message....</message>

<portType> definition of a port.......</portType>

<binding> definition of a binding....</binding>

</definitions>

http://grid.rit.edu 21

WSDL Ports

• The <portType> 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 <portType> element can be compared to a function library (or a module, or a class) in a traditional programming language.

http://grid.rit.edu 22

WSDL Bindings

• The <binding> element defines the message format and protocol details for each port.

• The binding element has two attributes - name and type.• The name attribute (you can use any name you want) defines the

name of the binding, and the type attribute points to the port for the binding.

• The soap:binding element has two attributes - style and transport.• The style attribute can be "rpc" or "document". In this case we use

document. The transport attribute defines the SOAP protocol to use. In this case we use HTTP.

• The operation element defines each operation that the port exposes.• For each operation the corresponding SOAP action has to be defined.

You must also specify how the input and output are encoded. In this case we use "literal".

http://grid.rit.edu 23

WSDL Example

http://grid.rit.edu 24

DEMO

http://grid.rit.edu 25

References

• www.wikipedia.com• http://www.w3schools.com/• http://msdn.microsoft.com/en-us/

default.aspx