21
Chapter 10 Chapter 10 Intro to SOAP and WSDL Intro to SOAP and WSDL

Chapter 10 Intro to SOAP and WSDL

  • Upload
    ailani

  • View
    63

  • Download
    0

Embed Size (px)

DESCRIPTION

Chapter 10 Intro to SOAP and WSDL. Objectives. By study in the chapter, you will be able to: Describe what is SOAP Exam the rules for creating a SOAP document Describe what is SOAP envelope Exam the purpose of the SOAP headers and how SOAP handles errors - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 10 Intro to SOAP and WSDL

Chapter 10Chapter 10Intro to SOAP and WSDL Intro to SOAP and WSDL

Page 2: Chapter 10 Intro to SOAP and WSDL

ObjectivesObjectivesBy study in the chapter, you will be able to:By study in the chapter, you will be able to:

Describe what is SOAPDescribe what is SOAP

Exam the rules for creating a SOAP document Exam the rules for creating a SOAP document

Describe what is SOAP envelope Describe what is SOAP envelope

Exam the purpose of the SOAP headers and how Exam the purpose of the SOAP headers and how SOAP handles errors SOAP handles errors

Describe what is WSDL and why we need WSDLDescribe what is WSDL and why we need WSDL

Exam what information is stored in the WSDL file and Exam what information is stored in the WSDL file and how WSDL is used in a Web service transactionhow WSDL is used in a Web service transaction

Questions and discussionsQuestions and discussions

HomeworkHomework

Page 3: Chapter 10 Intro to SOAP and WSDL

Concept of SOAPConcept of SOAP

What is SOAP?What is SOAP?– Stands for Simple Object Access ProtocolStands for Simple Object Access Protocol– Is interoperability specification and standard for Web Is interoperability specification and standard for Web

servicesservices– Provides a simple mechanism for making remote procedure Provides a simple mechanism for making remote procedure

calls and document exchanges using XMLcalls and document exchanges using XML

Why SOAP?Why SOAP?

- Easier to use- Easier to use

- Distributed computing- Distributed computing

- Accessibility- Accessibility

- XML based protocol- XML based protocol

Page 4: Chapter 10 Intro to SOAP and WSDL

Concept of SOAP (continue)Concept of SOAP (continue)

Why SOAP is different?Why SOAP is different?– Like a CORBA application, a call is made and a Like a CORBA application, a call is made and a

response is returned; unlike CORBA, in which a response is returned; unlike CORBA, in which a CORBA client actually makes calls to the object on CORBA client actually makes calls to the object on the server in a tightly coupled way, but a SOAP the server in a tightly coupled way, but a SOAP client just formats a text file and transfer it to the client just formats a text file and transfer it to the other machineother machine

– Is based on loosely coupled architecture, so there is Is based on loosely coupled architecture, so there is no challenge of the client program for the calls or no challenge of the client program for the calls or requests; therefore, it has casual relationship requests; therefore, it has casual relationship between clients and serversbetween clients and servers

– Supports just-in-time peer-to-peer discoverySupports just-in-time peer-to-peer discovery

Page 5: Chapter 10 Intro to SOAP and WSDL

The SOAP GrammarThe SOAP Grammar

The SOAP envelope contains both the header The SOAP envelope contains both the header and the SOAP bodyand the SOAP body

SOAP envelope

SOAP header (optional)

SOAP body

Page 6: Chapter 10 Intro to SOAP and WSDL

The SOAP Grammar (continue)The SOAP Grammar (continue)

SOAP envelope tag <SOAP-ENV:Envelope>SOAP envelope tag <SOAP-ENV:Envelope>– A SOAP message is defined as beginning with the A SOAP message is defined as beginning with the

tag <SOAP-ENV:Envelope>tag <SOAP-ENV:Envelope>– And ending with </SOAP-ENV:Envelope>And ending with </SOAP-ENV:Envelope>– We define XML namespace SOAP-ENV in the We define XML namespace SOAP-ENV in the

SOAP envelope tag. For example:SOAP envelope tag. For example:

<SOAP-ENV:Envelope xmlns:SOAP-ENV= <SOAP-ENV:Envelope xmlns:SOAP-ENV= “http://schemas.xmlsoap.org/soap/envelope”>“http://schemas.xmlsoap.org/soap/envelope”>

Page 7: Chapter 10 Intro to SOAP and WSDL

The SOAP Grammar (continue)The SOAP Grammar (continue)

SOAP header tag <SOAP-ENV:Header>SOAP header tag <SOAP-ENV:Header>– SOAP header tag is optionalSOAP header tag is optional– It must be the first child element in the SOAP It must be the first child element in the SOAP

envelope if it’s presentenvelope if it’s present– Since SOAP header tag is not defined in the Since SOAP header tag is not defined in the

SOAP specification, so it’s available to the clients SOAP specification, so it’s available to the clients and services for their own useand services for their own use

– Typically it’s used to communicate credential Typically it’s used to communicate credential such as user name and passwordsuch as user name and password

– Example of using the header tag (next slide)Example of using the header tag (next slide)

Page 8: Chapter 10 Intro to SOAP and WSDL

The SOAP Grammar (continue)The SOAP Grammar (continue)

Example of using the SOAP header tagExample of using the SOAP header tag

<SOAP-ENV:Header><SOAP-ENV:Header>

<myNS:authentication <myNS:authentication xmlns:myNS=“http://www.stevepotts.com/auth”xmlns:myNS=“http://www.stevepotts.com/auth”

SOAP:ENV:mustUnderstand=“1”> SOAP:ENV:mustUnderstand=“1”>

<login>admin</login><login>admin</login>

<password>admin</password><password>admin</password>

</myNS:authentication></myNS:authentication>

</SOAP-ENV:Header></SOAP-ENV:Header>

Page 9: Chapter 10 Intro to SOAP and WSDL

The SOAP Grammar (continue)The SOAP Grammar (continue)

The SOAP body tag <SOAP-ENV:Body>The SOAP body tag <SOAP-ENV:Body>– The body of the SOAP message begins with the tagThe body of the SOAP message begins with the tag

<SOAP-ENV:Body><SOAP-ENV:Body>– And ending with the tagAnd ending with the tag

</SOAP-ENV:Body></SOAP-ENV:Body>– Typically we place a remote call with the Typically we place a remote call with the

parameters in this tag. parameters in this tag. – Example (see next slide)Example (see next slide)

Page 10: Chapter 10 Intro to SOAP and WSDL

The SOAP Grammar (continue)The SOAP Grammar (continue)

Example of using the SOAP body tagExample of using the SOAP body tag

<SOAP-ENV:Body><SOAP-ENV:Body>

<checkAccountBalance><checkAccountBalance>

<accountNumber xsi:type=“xsd:int”>16888<accountNumber xsi:type=“xsd:int”>16888

</accountNumber></accountNumber>

</checkAccountBalance></checkAccountBalance>

</SOAP-ENV:Body></SOAP-ENV:Body>

Page 11: Chapter 10 Intro to SOAP and WSDL

The SOAP Grammar (continue)The SOAP Grammar (continue)

Error handling tagsError handling tags– Using the optional SOAP error handling tags, the Using the optional SOAP error handling tags, the

error message will be reported to the clienterror message will be reported to the client– SOAP has the following four optional tags:SOAP has the following four optional tags:

<SOAP-ENV:Faulcode><SOAP-ENV:Faulcode><SOPA-ENV:faultstring><SOPA-ENV:faultstring><SOPA-ENV:faultactor><SOPA-ENV:faultactor><SOPA-ENV:detail><SOPA-ENV:detail>

– Example (see next slide)Example (see next slide)

Page 12: Chapter 10 Intro to SOAP and WSDL

The SOAP Grammar (continue)The SOAP Grammar (continue)

Example of using the error handling tagExample of using the error handling tag

<SOAP-ENV:faultcode><SOAP-ENV:faultcode>

The error message to the client if it The error message to the client if it occursoccurs

</SOAP-ENV:faultcode></SOAP-ENV:faultcode>

Page 13: Chapter 10 Intro to SOAP and WSDL

How SOAP is usedHow SOAP is usedSOAP is the specification, not a softwareSOAP is the specification, not a software

SOAP document is an XML documentSOAP document is an XML document

We must have SOAP processors (parsers) at We must have SOAP processors (parsers) at both the client-side and the server-side to be both the client-side and the server-side to be able to handle a SOAP messageable to handle a SOAP message

We can write our SOAP applications with any We can write our SOAP applications with any computer languages at both endscomputer languages at both ends

Many Web services servers have provided Many Web services servers have provided SOAP processors (SOAP engines) for free to SOAP processors (SOAP engines) for free to promote the usages, so programmers don’t promote the usages, so programmers don’t need to know SOAP grammar in details need to know SOAP grammar in details

Page 14: Chapter 10 Intro to SOAP and WSDL

How SOAP is used (continue)How SOAP is used (continue)

Many computer languages, such as Java Many computer languages, such as Java and .NET, have Web services development and .NET, have Web services development packs, i.e., JAX-RPC and ASP.NET, to packs, i.e., JAX-RPC and ASP.NET, to create Web services applications without create Web services applications without knowing SOAP grammar in detailsknowing SOAP grammar in detailsWe will use such easy-to-use features to We will use such easy-to-use features to build our simple Web services application build our simple Web services application using Apache Axis and JAX-RPC in later using Apache Axis and JAX-RPC in later chapters chapters

Page 15: Chapter 10 Intro to SOAP and WSDL

WSDL and WSDL documentWSDL and WSDL document

WSDL (Web Services Description Language) is WSDL (Web Services Description Language) is a specification that tells us how to describe a a specification that tells us how to describe a Web serviceWeb service

WSDL document follows XML grammar and WSDL document follows XML grammar and stored in the Web services server, such as stored in the Web services server, such as http://www.xmethods.comhttp://www.xmethods.com, to communicate , to communicate metadata about a Web service to all potential metadata about a Web service to all potential clients clients

The basic operations that use the WDSL are The basic operations that use the WDSL are find, bind, and publish (see next slide)find, bind, and publish (see next slide)

Page 16: Chapter 10 Intro to SOAP and WSDL

WSDL and WSDL document (continue)WSDL and WSDL document (continue)

Example of how WDSL works Example of how WDSL works

Web services directory

Client (Web service customer)

Web service provider

find publish

bind

Page 17: Chapter 10 Intro to SOAP and WSDL

WSDL and WSDL document (continue)WSDL and WSDL document (continue)

There are two types of WSDL document:There are two types of WSDL document:– The concrete descriptionThe concrete description– The abstract descriptionThe abstract description

There are four abstract XML elements that can There are four abstract XML elements that can be defined in a WSDL file as follows:be defined in a WSDL file as follows:<wsdl:types> -- describe data types<wsdl:types> -- describe data types<wsdl:message> -- <wsdl:message> -- describe request/response messagedescribe request/response message

<wsdl:operation> -- describe method calls<wsdl:operation> -- describe method calls<wsdl:portType> -- it contains all operations<wsdl:portType> -- it contains all operations

Page 18: Chapter 10 Intro to SOAP and WSDL

WSDL and WSDL document (continue)WSDL and WSDL document (continue)

There are three concrete XML elements in a There are three concrete XML elements in a WSDL file:WSDL file:<wsdl:service> -- contains all ports in the WSDL<wsdl:service> -- contains all ports in the WSDL

<wsdl:port> -- contains IP address and port of the <wsdl:port> -- contains IP address and port of the Web serviceWeb service

<wsdl:binding> -- <wsdl:binding> -- contains information how to contains information how to physically connect to all of the Web physically connect to all of the Web

services, respectively services, respectively

In addition, there is a root element In addition, there is a root element <wsdl:definitions> -- <wsdl:definitions> -- specify the targetNameSpacespecify the targetNameSpace

Example of a WSDL documentExample of a WSDL document– http://www.xmethods.comhttp://www.xmethods.com

Page 19: Chapter 10 Intro to SOAP and WSDL

HTTP communication handshakeHTTP communication handshake

Page 20: Chapter 10 Intro to SOAP and WSDL

Questions and DiscussionQuestions and Discussion

Page 21: Chapter 10 Intro to SOAP and WSDL

Homework for Extra PointsHomework for Extra Points

Use of goole search to find out SOAP Use of goole search to find out SOAP tutorial’s appendix, and write down how tutorial’s appendix, and write down how many data types it supportsmany data types it supports

Summarize why is the WSDL needed Summarize why is the WSDL needed

Due: Wednesday, June 8, 2005 in the classDue: Wednesday, June 8, 2005 in the class