Survey of Designing Web and Tools

fishnibblersspongySoftware and s/w Development

Dec 14, 2013 (3 years and 5 months ago)

59 views

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

Describe what is WSDL and why we need WSDL

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

Questions and discussions

Homework


Concept of SOAP

What is SOAP?


Stands for Simple Object Access Protocol


Is interoperability specification and standard for Web
services


Provides a simple mechanism for making remote procedure
calls and document exchanges using XML

Why SOAP?


-

Easier to use


-

Distributed computing


-

Accessibility


-

XML based protocol



Concept of SOAP (continue)

Why SOAP is different?


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


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


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










The SOAP Grammar

The SOAP envelope contains both the header
and the SOAP body








SOAP envelope









SOAP header (optional)


SOAP body



The SOAP Grammar (continue)

SOAP envelope tag <SOAP
-
ENV:Envelope>


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


And ending with </SOAP
-
ENV:Envelope>


We define XML namespace SOAP
-
ENV in the
SOAP envelope tag. For example:



<SOAP
-
ENV:Envelope xmlns:SOAP
-
ENV=


“http://schemas.xmlsoap.org/soap/envelope”>









The SOAP Grammar (continue)

SOAP header tag <SOAP
-
ENV:Header>


SOAP header tag is optional


It must be the first child element in the SOAP
envelope if it’s present


Since SOAP header tag is not defined in the
SOAP specification, so it’s available to the clients
and services for their own use


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


Example of using the header tag (next slide)



The SOAP Grammar (continue)

Example of using the SOAP header tag


<SOAP
-
ENV:Header>


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






SOAP:ENV:mustUnderstand=“1”>



<login>admin</login>



<password>admin</password>


</myNS:authentication>

</SOAP
-
ENV:Header>


The SOAP Grammar (continue)

The SOAP body tag <SOAP
-
ENV:Body>


The body of the SOAP message begins with the tag


<SOAP
-
ENV:Body>


And ending with the tag


</SOAP
-
ENV:Body>


Typically we place a remote call with the
parameters in this tag.


Example (see next slide)









The SOAP Grammar (continue)

Example of using the SOAP body tag


<SOAP
-
ENV:Body>


<checkAccountBalance>



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



</accountNumber>


</checkAccountBalance>

</SOAP
-
ENV:Body>





The SOAP Grammar (continue)

Error handling tags


Using the optional SOAP error handling tags, the
error message will be reported to the client


SOAP has the following four optional tags:

<SOAP
-
ENV:Faulcode>

<SOPA
-
ENV:faultstring>

<SOPA
-
ENV:faultactor>

<SOPA
-
ENV:detail>


Example (see next slide)









The SOAP Grammar (continue)

Example of using the error handling tag





<SOAP
-
ENV:faultcode>



The error message to the client if it occurs


</SOAP
-
ENV:faultcode>




How SOAP is used

SOAP is the specification, not a software

SOAP document is an XML document

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

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

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

How SOAP is used (continue)


Many computer languages, such as Java
and .NET, have Web services development
packs, i.e., JAX
-
RPC and ASP.NET, to
create Web services applications without
knowing SOAP grammar in details

We will use such easy
-
to
-
use features to
build our simple Web services application
using Apache Axis and JAX
-
RPC in later
chapters



WSDL and WSDL document

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

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

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


WSDL and WSDL document (continue)

Example of how WDSL works

Web services directory


Client (Web
service customer)


Web service provider



find

publish

bind

WSDL and WSDL document (continue)

There are two types of WSDL document:


The concrete description


The abstract description

There are four abstract XML elements that can
be defined in a WSDL file as follows:

<wsdl:types>
--

describe data types

<wsdl:message>
--

describe request/response message

<wsdl:operation>
--

describe method calls

<wsdl:portType>
--

it contains all operations



WSDL and WSDL document (continue)

There are three concrete XML elements in a
WSDL file:

<wsdl:service>
--

contains all ports in the WSDL

<wsdl:port>
--

contains IP address and port of the



Web service

<wsdl:binding>
--

contains information how to







physically connect to all of the Web






services, respectively

In addition, there is a root element
<wsdl:definitions>
--

specify the targetNameSpace

Example of a WSDL document


http://www.xmethods.com






HTTP communication handshake

Questions and Discussion

Homework for Extra Points

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

Summarize why is the WSDL needed


Due: Wednesday, June 8, 2005 in the class