Upload
sarah-elliott
View
220
Download
0
Embed Size (px)
Citation preview
Transport Protocols
SOAP is used to send a message over any kind of transport protocol. Some of the protocols are,
1. HTTP2. TCP/IP3. UDP4. SMTP
1. HTTP• It is a connection-oriented protocol that is
based on request and response message.• Ex. Request Message
GET /cweb/crservice.html HTTP/1.1
• Ex. Response MessageHTTP/1.1 200 okContent-Type : text/xml
character=utf-8Content-Length : nnn<html> <body>
This is a Html page. </body> </html>
2. TCP/IP
It is a connection-oriented protocol. Enables to send message in sequence
and receive acknowledgement of delivery and can have retransmission of messages
Messages are called as packets. Each packet can have 65535 bytes.
TCP/IP format
3. UDP
It is a connectionless protocolNo acknowledgement for received
messagesNo servers, Everyone can listen and
send.Unreliable.
UDP format
4. SMTP
It is the protocol to send e-mail messages
It is Connection-oriented It looks similar to http messages but
reliable. All smtp data is 7-bit ASCII with high-
order bit always 0. Always use port-25
Messaging with Web Services
• Refer Hard copy Notes
SOAP (Simple Object Access Protocol)
SOAP SPECIFICATIONS The Simple Object Access Protocol
(SOAP) is an XML-based messaging and remote procedure call (RPC) specification that enables the exchange of information among distributed systems.
Initially proposed by Microsoft, SOAP has established itself as the de facto standard for an open, extensible, XML-based wire protocol.
SOAP has achieved its level of widespread acceptance for several reasons:1.It is an open specification, available for anyone to use.2.It is simple to write and is “human-readable.”3.It is extensible, taking advantage of the power of XML to enable loose coupling between remote systems.4.It is a flexible protocol that is useful both in request / response and message passing/queuing architectures.
SOAP provides three key capabilities:1.SOAP is a messaging framework, consisting of an outer Envelope element that contains an optional Header element and a mandatory Body element.2.SOAP is an encoding format that describes how objects are encoded, serialized, and how decoded when received.3.SOAP is an RPC mechanism that enables objects to call methods of remote objects.
Capabilities of SOAP
SOAP MESSAGE STRUCTURE
SOAP Envelope Element The SOAP Envelope element is the
mandatory top element of the XML document that represents the SOAP message being sent.
It may contain namespace declarations as well as other attributes.
The namespace, http://schemas.xmlsoap.org/soap/envelope/, is required by all SOAP messages.
NAMESPACES
xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/”
xmlns:xsi=”http://www.w3.org/1999/XMLSchema-instance”
xmlns:xsd=”http://www.w3.org/1999/XMLSchema”
SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
Header Element• Optional element offers a flexible framework for specifying
additional application-level requirements.• Provides an open mechanism for authentication, transaction
management and payment authorization.• It specifies two attributes.• A) Actor :
– Is used to point out the next target in the message hop.– Value of the <actor> attribute is the URL of the next endpoint.– The absence of <actor> indicates that the next endpoint is the
ultimate recipient.
• B) MustUnderstand : – Indicates whether a header element is optional or mandatory. If set to
True, the recipient must understand and process the Header attribute according to its defined semantics or return a fault.
BODY Element• This is mandatory for all SOAP messages.• It carries the payload of the soap message
which will be processed by the ultimate receiver.
Body ( required)
Fault ( Optional )
Fault• In the event of an error, the body element will
include a fault element.• Fault Subelements :
i. faultCode : a text code used to indicate a class of errorsii. faultString : a human-readable explanation of the error.iii. faultActor : a text string indicating which node causes fault.iv. detail : to carry error message and the child element entries.
• Fault Codes :• SOAP-ENV : VersionMismatch - invalid namespace• SOAP-ENV : mustUnderstand - Unable to process mustUnderstand
attribute• SOAP-ENV : Client – client request has error• SOAP-ENV : Server is unable to process the client request.
SOAP ENCODING• SOAP includes a built-in set of rules for
encoding data types.• this enables the soap message to indicate
specific data types like integers, floats, doubles or arrays.
• SOAP datatypes are divided into two types.A. Scalar type :
• contain exactly one value like lastname, price, qty, …• The datatypes are string, boolean, float, double,
binary, integer, long , byte, ….etc.,
B. Compound type : – Contain multiple values like purchase order, invoice,
..etc.,– It is further divided into two.
• Array : contain multiple values with position no.• Struct : contain multiple values and each element
specified by an accessor name.Ex.) To specify an array of 10 double values,
arrayType = “xsi:double[10]” For two dimensional,
arrayType = “xsi:string[5,5]”Namespace used for SOAP-Encoding are,For SOAP1.1,
http://schemas.xmlsoap.org/soap/encodingFor SOAP1.2, http://www.w3.org/2001/09/soap-encoding
Weather Service
SOAP Client
SOAP Request : What is the temp. for Zip=10016 ?
SOAP Client
SOAP Response : 71 F
WSDL(Web Service Description Language)
Describing web services – WSDL WSDL is a specification defining how to describe web services in a common XML grammar. WSDL describes four critical pieces of data:
Interface information describing all publicly available
functions
Data type information for all message requests and
message responses
Binding information about the transport protocol to be
used
Address information for locating the specified service
WSDL SpecificationThe specification itself is divided into six major elements:
1. Definitions 2. Types3. Message4. PortType5. Binding6. Service
It has the following utility elements:
1. Documentation2. import
1. Definitions :
The definitions element must be the root element of all WSDL
documents. It defines the name of the web service, declares multiple
namespaces used throughout the remainder of the document, and contains all
the service elements described here.EX)<definitions name="HelloService" targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl"xmlns="http://schemas.xmlsoap.org/wsdl/"xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
The targetNamespace is a convention of XML Schema that enables the WSDL document to refer to itself.
xmlns=http://schemas.xmlsoap.org/wsdl/ is the default namespace.
2. Types
The types element describes all the data types used between the
client and server. WSDL is not tied exclusively to a specific typing system,
but it uses the W3C XML Schema specification as its default choice. If the
service uses only XML Schema built-in simple types, such as strings and
integers, the types element is not required.
3. Message
The message element describes a one-way message, whether it is a single
message request or a single message response. It defines the name of the
message and contains zero or more message part elements, which can
refer to message parameters or message return values.
Ex) for Message element
Two message elements are defined.
The first represents a request message, SayHelloRequest, and the second
represents a response message, SayHelloResponse:
<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</message>
Each of these messages contains a single part element. For the request, the
part specifies the function parameters; For the response, the part specifies the
function return values;
4. PortType :
The portType element combines multiple message elements to form a complete oneway or round-trip operation. For example, a portType can combine one request and one response message into a single request/response operation, most commonly used in SOAP services. Ex)
<portType name="Hello_PortType"><operation name="sayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/></operation>
</portType>
The portType element defines a single operation, called sayHello. The operation itself consists of a single input message (SayHelloRequest) and a single output message (SayHelloResponse):
The input element specifies a message attribute of tns:SayHelloRequest ; the tns prefix references the targetNamespace defined earlier within the definitions element.
Patterns of operation
a. One-way
The service receives a message. The operation therefore has a single input
element.
b. Request-response
The service receives a message and sends a response. To encapsulate errors,
an optional fault element can also be specified.
c. Solicit-response
The service sends a message and receives a response. The operation therefore
has one output element, followed by one input element. To encapsulate errors,
an optional fault element can also be specified.
d. Notification
The service sends a message. The operation therefore has a single output
element.
5. Binding
The binding element describes the concrete specifics of how the service will
be implemented on the wire. The binding element itself specifies name and
type attributes:Ex)<binding name="Hello_Binding" type="tns:Hello_PortType">
The type attribute references the portType
6. Service
The service element defines the address for invoking the specified service.
Most commonly, this includes a URL for invoking the SOAP service.
WSDL specification also defines the following utility elements:
1. Documentation :
The documentation element is used to provide human-readable
documentation and can be included inside any other WSDL element.
2. Import :
The import element is used to import other WSDL documents or XML
Schemas. This enables more modular WSDL documents. For example, two
WSDL documents can import the same basic elements and yet include their
own service elements to make the same service available at two physical
addresses.
Utility Elements in WSDL
WS-Policy
• Refer Hard copy Notes
WS-Inspection
• is a simple XML grammar for gathering services together.
• used to inspect endpoints like root of a web server and to find which services the endpoint offers.
• is a document with extension .wsil
Anatomy of WS-Inspection
• WS_Inspection documents have a root element with the local name and has the namespace,<inspection xmlns = "http://schemas.xmlsoap.org/ws/2001/10/inspection"/>
• Within the root element there can be service elements which can contain many description elements.
EX)<inspection xmlns = "http://schemas.xmlsoap.org/ws/2001/10/inspection"/>
<service><description
referredNamespace = "http://schemas.xmlsoap.org/wsdl/"location = "http://test.com/service.asmx?wsdl"/>
</service></inspection>
END OF III UNIT