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
- Web services can be used by other applications
- XML is the basis for Web services
Web services platform elements
- SOAP (Simple Object Access Protocol)
- UDDI (Universal Description, Discovery and Integration)
- WSDL (Web Services Description Language)

The body of the http:
Example
1
SOAP
1.1
Request
/
Response via HTTP

<?
xml version
=
"
1.0
"
?>
<
definitions name
=
"
StockQuote
"

targetNamespace
=
"
http://example.com/stockquote.wsdl
"
xmlns:tns
=
"
http://example.com/stockquote.wsdl
"
xmlns:xsd1
=
"
http://example.com/stockquote.xsd
"
xmlns:soap
=
"
http://schemas.xmlsoap.org/wsdl/soap/
"
xmlns
=
"
http://schemas.xmlsoap.org/wsdl/
"
>

<
types
>
<
schema targetNamespace
=
"
http://example.com/stockquote.xsd
"
xmlns
=
"
http://www.w3.org/2000/10/XMLSchema
"
>
<
element name
=
"
TradePriceRequest
"
>
<
complexType
>
<
all
>
<
element name
=
"
tickerSymbol
"
type
=
"
string
"
/>
</
all
>
</
complexType
>
</
element
>
<
element name
=
"
TradePrice
"
>
<
complexType
>
<
all
>
<
element name
=
"
price
"
type
=
"
float
"
/>
</
all
>
</
complexType
>
</
element
>
</
schema
>
</
types
>

<
message name
=
"
GetLastTradePriceInput
"
>
<
part name
=
"
body
"
element
=
"
xsd1:TradePriceRequest
"
/>
</
message
>

<
message name
=
"
GetLastTradePriceOutput
"
>
<
part name
=
"
body
"
element
=
"
xsd1:TradePrice
"
/>
</
message
>

<
portType name
=
"
StockQuotePortType
"
>
<
operation name
=
"
GetLastTradePrice
"
>
<
input message
=
"
tns:GetLastTradePriceInput
"
/>
<
output message
=
"
tns:GetLastTradePriceOutput
"
/>
</
operation
>
</
portType
>

<
binding name
=
"
StockQuoteSoapBinding
"
type
=
"
tns:StockQuotePortType
"
>
<
soap:binding style
=
"
document
"
transport
=
"
http://schemas.xmlsoap.org/soap/http
"
/>
<
operation name
=
"
GetLastTradePrice
"
>
<
soap:operation soapAction
=
"
http://example.com/GetLastTradePrice
"
/>
<
input
>
<
soap:body use
=
"
literal
"
/>
</
input
>
<
output
>
<
soap:body use
=
"
literal
"
/>
</
output
>
</
operation
>
</
binding
>

<
service name
=
"
StockQuoteService
"
>
<
documentation
>
My first service
</
documentation
>
<
port name
=
"
StockQuotePort
"
binding
=
"
tns:StockQuoteBinding
"
>
<
soap:address location
=
"
http://example.com/stockquote
"
/>
</
port
>
</
service
>

</
definitions
>

WSDL:
A WSDL document
is
simply a
set
of definitions. There
is
a definitions element at the root, and definitions inside. The grammar
is
as
follows:

<
wsdl:definitions name
=
"
nmtoken
"
?
targetNamespace
=
"
uri
"
?>

<
import
namespace
=
"
uri
"
location
=
"
uri
"
/>*

<
wsdl:documentation
.
/>
?

<
wsdl:types
>
?
<
wsdl:documentation
.
/>?
<
xsd:schema
.
/>*
<--
extensibility element
-->
*
</
wsdl:types
>

<
wsdl:message name
=
"
nmtoken
"
>
*
<
wsdl:documentation
.
/>?
<
part name
=
"
nmtoken
"
element
=
"
qname
"
?
type
=
"
qname
"
?/>
*
</
wsdl:message
>

<
wsdl:portType name
=
"
nmtoken
"
>*
<
wsdl:documentation
.
/>?
<
wsdl:operation name
=
"
nmtoken
"
>*
<
wsdl:documentation
.
/>
?
<
wsdl:input name
=
"
nmtoken
"
?
message
=
"
qname
"
>?
<
wsdl:documentation
.
/>
?
</
wsdl:input
>
<
wsdl:output name
=
"
nmtoken
"
?
message
=
"
qname
"
>?
<
wsdl:documentation
.
/>
?
</
wsdl:output
>
<
wsdl:fault name
=
"
nmtoken
"
message
=
"
qname
"
>
*
<
wsdl:documentation
.
/>
?
</
wsdl:fault
>
</
wsdl:operation
>
</
wsdl:portType
>

<
wsdl:binding name
=
"
nmtoken
"
type
=
"
qname
"
>*
<
wsdl:documentation
.
/>?
<--
extensibility element
-->
*
<
wsdl:operation name
=
"
nmtoken
"
>*
<
wsdl:documentation
.
/>
?
<--
extensibility element
-->
*
<
wsdl:input
>
?
<
wsdl:documentation
.
/>
?
<--
extensibility element
-->
</
wsdl:input
>
<
wsdl:output
>
?
<
wsdl:documentation
.
/>
?
<--
extensibility element
-->
*
</
wsdl:output
>
<
wsdl:fault name
=
"
nmtoken
"
>
*
<
wsdl:documentation
.
/>
?
<--
extensibility element
-->
*
</
wsdl:fault
>
</
wsdl:operation
>
</
wsdl:binding
>

<
wsdl:service name
=
"
nmtoken
"
>
*
<
wsdl:documentation
.
/>?
<
wsdl:port name
=
"
nmtoken
"
binding
=
"
qname
"
>
*
<
wsdl:documentation
.
/>
?
<--
extensibility element
-->
</
wsdl:port
>
<--
extensibility element
-->
</
wsdl:service
>

<--
extensibility element
-->
*

</
wsdl:definitions
>

Services are defined using six major elements:
- types, which provides data type definitions used to describe the messages exchanged.
- message, which represents an abstract definition of the data being transmitted. A message consists of logical parts, each of which is associated with a definition within some type system.
- portType, which is a set of abstract operations. Each operation refers to an input message and output messages.
- binding, which specifies concrete protocol and data format specifications for the operations and messages defined by a particular portType.
- port, which specifies an address for a binding, thus defining a single communication endpoint.
- service, which is used to aggregate a set of related ports.
You can put the Web Service on your site.
<
form target
=
"
_blank
"
action
=
'
http://www.w3schools.com
/
webservices
/
tempconvert.asmx
/
FahrenheitToCelsius
'
method
=
"
POST
"
>
<
table
>
<
tr
>
<
td
>
Fahrenheit to Celsius:
</
td
>
<
td
><
input
class
=
"
frmInput
"
type
=
"
text
"
size
=
"
30
"
name
=
"
Fahrenheit
"
></
td
>
</
tr
>
<
tr
>
<
td
></
td
>
<
td align
=
"
right
"
>
<
input type
=
"
submit
"
value
=
"
Submit
"
class
=
"
button
"
></
td
>
</
tr
>
</
table
>
</
form
>