Web Services Assignment
Web Services Assignment
Web Services Assignment
Assignment 02
Mathoaarachchi Y T
E121041035
ITE 3108
E121041035
Part 01
Question A
What are Web Services? Briefly explain using your own words.
Web services also called as application
services. Web services are the very
important building blocks in the move to
distributed computing on the internet. In
other words we can say a web service is a
collection of open protocols and standards
used for swapping data between applications or systems. Open standards and the focus on
communication and collaboration between people and applications have created an environment
where Web services are becoming the platform for application integration. Applications are
constructed using multiple Web services from many sources that work together irrespective of
where they reside or how they were implemented.
Behavioral Characteristics of web services are
XML based: Web services uses XML at data representation and data transportation layers.
Loosely Coupled: The Web service interface can change over time without compromising
the clients ability to interact with the service.
Also Web services describes an identical way of integrating Web-based applications using the
XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone.
ITE 3108
E121041035
Web service is identified by a URL, just like any other Web site. The difference lies in the content
of what is sent in the request from the client to the service. There are lots of advantages of web
services. Some of them are
Versatility: They can be accessed by humans via a Web-based client interface, or they
can be accessed by other applications and other Web services.
Reusability: One service might be utilized by several clients, all of which employ the
operations provided to fulfill different business objectives.
Standardized Protocol: Web Services uses standardized industry standard protocol for
the communication.
Cost Saving: All these benefits add up to significant cost savings. Easy interoperability
means the need to create highly customized applications for integrating data, which can be
expensive, is removed.
ITE 3108
E121041035
Question B
What is SOAP? Explain its purpose.
SOAP stands for Simple Object Access Protocol. Soap is the application communications protocol
for XML Web services. SOAP is a specification that defines the XML format for messages. Some
characteristics of SOAP are:
Message format
Protocol extensibility
SOAP Advantages:
Platform independent.
Language independent.
Vendor neutral.
ITE 3108
E121041035
SOAP Disadvantages:
SOAP 1.1 dont specify a default encoding for the message body.
SOAP deals with objects serialized to plain text and not with stringified remote object
references (interoperable object references, IORs, as defined in CORBA), distributed
garbage collection has no meaning.
SOAP specifies precisely how to encode an HTTP header and an XML file so that a
program in one computer can call a program in an additional computer and pass along
information.
SOAP also specifies how the called program can return a response. Despite its frequent
combination with HTTP, SOAP supports other transport protocols as well.
A web service wants a mixture of XML, HTTP and a protocol under the category
application-specific. A web service uses XML data for exchanging. The weather service,
stock quote service, look up service of postal department are all sending XML messages
and receiving an XML reply. This is the pattern that dominates the web services. To
perform these web services, SOAP is the reliable protocol.
Question C
What are the elements that should be contained in a SOAP message?
There are 4 elements in SOAP message. They are
1. The SOAP Envelope (Required)
2. The SOAP Header (Optional)
3. The SOAP Body (Required)
4. The SOAP Fault (Optional)
ITE 3108
E121041035
<Envelope> is the root element in every SOAP message and it is mandatory part of SOAP
message. It defines the start and the end of the message.
Start Envelope Tag <SOAP-Envelope>
End Envelope Tag </SOAP-Envelope>
It contains two child elements. They are an optional <Header> element, and a mandatory
<Body> element.
If an Envelope contains a Header element, it must contain no more than one, and it must
appear as the very first child of the Envelope, before the Body.
The SOAP envelope is specified using the ENV namespace prefix and the Envelope
element.
Ex:
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
...
Rest of the message
...
</soap:Envelope>
ITE 3108
E121041035
The header is encoded as the first immediate child element of the SOAP envelope.
When more than one header is defined in the SOAP message, all immediate child elements
of the SOAP header are interpreted as SOAP header blocks.
Actor attribute: The SOAP protocol defines a message path as a list of SOAP service
nodes. By setting the Actor attribute, the client can specify the recipient of the SOAP
header.
ITE 3108
E121041035
In other words we can say, this is the element which contains call and response information
or else in other words body element contains the application defined XML data that are
being exchanged in the SOAP message.
Ex:
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
<m:GetPrice xmlns:m="http://www.w3schools.com/prices">
<m:Item>Apples</m:Item>
</m:GetPrice>
</soap:Body>
</soap:Envelope>
The SOAP Fault:
<Fault> is a sub-element of the SOAP body and Fault element is an elective part of
SOAP Message.
Start Fault Tag <SOAP-Fault>
End Fault Tag </SOAP-Fault>
It is used for reporting errors. Including a predefined code, a description, and the address
of the SOAP processor that made and also SOAP Message can carry only one fault block.
For the HTTP binding, a positive response is linked to the 200 to 299 range of status
codes.
The SOAP Fault element has the 4 sub elements. They are;
<faultcode>: A code for identifying the fault
<faultstring>: A human readable explanation of the fault
<faultactor>: Information about who caused the fault to happen
8
ITE 3108
E121041035
ITE 3108
E121041035
xmlns:ns="http://www.romapizza.com/order"
ns:mustUnderstand="1">
<ns:session_id>123456789</ns:session_id>
</ns:session>
</SOAP-ENV:Header>
//SOAP Body
<SOAP-ENV:Body>
<GetPizza xmlns="http://www.romapizza.com/order">
<customer_name>Yasanthika Tharangani</customer_name>
<address>Kalutara</address>
<phoneNo>0716466137</phoneNo>
<pizzaId>pid001</pizzaId>
<pizzaName>Cheesy Hotdog Crown</pizzaName>
<topping>Add Mushroom</topping>
<beverage>Sprite</beverage>
</GetPizza>
//SOAP Fault
10
ITE 3108
<SOAP-ENV:Fault>
<SOAP-ENV:faultstring>
Required data must be filled
</SOAP-ENV:faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
11
E121041035
ITE 3108
E121041035
Question E
Riku-Navi is a company that facilitates students and other Job seekers by providing
information of various companies. To find company details, a SOAP request
GetCompanyDetail() is sent to the server with the company id as the parameter. In response,
details of company are returned via XML. Write appropriate SOAP request and response
messages
with
headers.
The
namespace
for
the
function
is
defined
in
"http://www.rikunavi.org/cmpinfo".
(The program files of the below source codes are also attached in the ITE3108d_E121041035
folder)
12
ITE 3108
E121041035
ITE 3108
14
E121041035
ITE 3108
E121041035
<jobid>1</jobid>
15
ITE 3108
</jobList>
</companyRes>
</GetCompanyDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
16
E121041035
ITE 3108
17
E121041035
ITE 3108
E121041035
Part 2
Question A
WSDL supports four operation types. List them and briefly explain what they are, in your
Own words.
There are 4 operation types
1.
3.
ITE 3108
E121041035
Request-Response:
A Request/response operation is an operation in which the service end point receives a message
and returns a message in response. In other words we can say, if an <operation> element is
declared with a single <input> element followed by a single <output> element, that means it is a
request/response operation.
Example Code:
<wsdl:definitions .... >
<wsdl:portType .... >
<wsdl:operation name="nmtoken" parameterOrder="nmtokens">
<wsdl:input name="nmtoken"? message="qname"/>
<wsdl:output name="nmtoken"? message="qname"/>
<wsdl:fault name="nmtoken" message="qname"/>*
</wsdl:operation>
</wsdl:portType >
</wsdl:definitions>
Solicit/response operation
A solicit/response operation is an operation in which the service endpoint sends a message and
expects to receive an answering message in response. This Operation is the opposite of the
request/response operation. In other way round, Solicit/response is similar to notification
messaging, except that the client is expected to respond to the Web service. With this type of
messaging the <portType> element first declares an <output> tag and then a <input> message
definition exactly the reverse of a request/response operation.
Ex: service that sends out order status to a client and receives back a receipt.
Example Code:
<wsdl:definitions .... >
<wsdl:portType .... >
19
ITE 3108
E121041035
20
ITE 3108
E121041035
Question B
How do you define Binding in WSDL? Elaborate the answer in your own words.
Binding:
Binding is an element in WSDL document and it defines how message are transmitted, and the
location of the service. The <binding> element provides specific details on how a portType
operation will really be transmitted over the wire. The bindings can be made available through
numerous transports including HTTP GET, HTTP POST, or SOAP. It provides concrete
information on what protocol is being used to transfer <portType> operations. We can specify
numerous bindings for a single portType. The binding element has two attributes. They are name
and type attribute. The name attribute defines the name of the binding, and the type attribute
points to the port for the binding.
Ex: <binding name="Hello_Binding" type="tns:Hello_PortType">
Binding Element:
Concrete protocols: SOAP or HTTP
Messaging styles: RPC or documents styles
Formatting (encoding) styles: literal or SOAP encoding.
For SOAP protocol, the binding is <soap:binding>, and the transport is SOAP messages on top
of HTTP protocol.
SOAP Binding:
WSDL 1.1 includes built-in extensions for SOAP 1.1. It allows you to specify SOAP specific
details including SOAP headers, SOAP encoding styles, and the SOAPAction HTTP header. The
SOAP extension elements include:
soap:binding: This element indicates that the binding will be made available via SOAP.
soap:operation: This element indicates the binding of a specific operation to a specific
SOAP implementation.
soap:body: This element enables you to specify the details of the input and output
messages.
21
ITE 3108
E121041035
Example Code:
<binding name="Hello_Binding" type="tns:Hello_PortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/ >
<operation name="sayHello">
<soap:operation soapAction="sayHello"/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice" use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:helloservice" use="encoded"/>
</output>
</operation>
</binding>
Question C
Briefly explain two limitations of WSDL.
WSDL incapability of being able to describe complex business Web services, which
normally are constituted by scoring multiple finergrained Web services. This disadvantage
is because of the absence of support for workflow descriptions in WSDL. In other words
we can say only supports connecting via the web server. That means authentication
required for every request.
This model containing service semantic clarifications, extension mechanisms, and the
support for new constructs in the SOAP 1.2 specification.
No configurable caching. That means all caching must be coded into application
22
ITE 3108
E121041035
ITE 3108
E121041035
<sequence>
<!the following lines describe the element names and their types which comes
under the companyDetails element-->
<element name="companyid" type="integer" />
<element name="companyname" type="string" />
<element name="companytelephoneno" type="string" />
<element name="companyaddress" type="string" />
<!jobList element is a complex type therefore it is further describes as below-->
<element name="jobList">
<complexType>
<sequence>
<!the following lines describe the element names and their types which comes
under the jobList complextype element-->
<element name="jobid" type="integer" />
<element name="jobtitle" type="string" />
<element name="jobtype" type="string" />
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</types>
<! -- Message elements describe potential transactions -->
<! -- Request GetCompanyDetail is of type GetCompanyDetail-->
<message name="GetCompanyDetail">
24
ITE 3108
E121041035
25
ITE 3108
<output><soap:body use="literal"/></output>
</operation>
</binding>
<! -- service names a new service "getService" -->
<service name="getService">
<documentation>Web Service Discription Language for Getting Company
Information</documentation>
<! -- connect it to the binding "infor_binding" above -->
<port binding="infor_binding" name="infor_port">
<! -- give the binding a network address -->
<soap:address location="http://www.rukinavi.org/GetCompanyDetail" />
</port>
</service>
</definitions>
26
E121041035
ITE 3108
27
E121041035
ITE 3108
E121041035
Question E
Elaborately explain the following WSDL documents in your own words.
<! -- Own namespace for wdsl (I assumed the snowboard as the service provider
therefore I considered this as a own namespace) -- >
targetNamespace="http://namespaces.snowboard-info.com"
xmlns:es="http://www.snowboard-info.com/EndorsementSearch.wsdl"
<! -- Own namespace for xsd (I assumed the snowboard as the service provider
therefore I considered this as a own namespace) -- >
xmlns:esxsd=http://schemas.snowboard- info.com/EndorsementSearch.xsd
<! -- omitted types section with content model schema info --> //comment
<! -- This line of the document specifies the data type and the esxsd is the
namespace. -- >
<part name="body" element="esxsd:GetEndorsingBoarder"/>
</message>
28
ITE 3108
E121041035
<! -- //this is the operation name inside this there are three operation types as
input, output and fault as follow -- >
<operation name="GetEndorsingBoarder">
<! -- If there is any error in the request or response we can use this error part to
indicate that error -- >
<fault message="es:GetEndorsingBoarderFault"/>
</operation>
</portType>
29
ITE 3108
E121041035
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<! -- define operation name and soap action as in to where it is referred to -- >
<operation name="GetEndorsingBoarder">
<soap:operation
soapAction="http://www.snowboard-info.com/EndorsementSearch"/>
<input>
<! -- literal is used to specify how the output is encoded and the namespace is
taken using the above mentioned schema -- >
<soap:body use="literal"
namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
</input>
<output>
<! -- literal is used to specify how the output is encoded and the namespace is
taken using the above mentioned schema -- >
<soap:body use="literal"
namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
</output>
<fault>
<! -- //literal is used to specify how the fault is encoded and the namespace is
taken using the above mentioned schema -- >
<soap:body use="literal"
namespace="http://schemas.snowboard-info.com/EndorsementSearch.xsd"/>
</fault>
</operation>
</binding>
ITE 3108
E121041035
31