Friday, March 15, 2019

Tutorial 05 – Web services and SOAP

PROGRAMMING APPLICATIONS AND FRAMEWORKS                                              
Tutorial 05


1. Compare and contrast web applications with web services, indicating the need for web services 



Web service is a technology by which two or more remote web applications interact with each other over network/internet. It can be implemented using Java, .net, PHP etc. Web pages allow people to communicate and collaborate with each other while web services allow programs to communicate and collaborate with each other.
All the standard Web Services works using following components:
  • SOAP (Simple Object Access Protocol)
  • UDDI (Universal Description, Discovery and Integration)
  • WSDL (Web Services Description Language)
  • XML
Web Application:- An application that the users access over the internet is called a web application Generally, any software that is accessed through a client web browser could be called a web application.

Web Services vs Web Applications
  • Web Services can be used to transfer data between Web Applications.
  • Web Services can be accessed from any languages or platform.
  • A Web Application is meant for humans to read, while a Web Service is meant for computers to read.
  • Web Application is a complete Application with a Graphical User Interface (GUI), however, web services do not necessarily have a user interface since it is used as a component in an application.
  • Web Application can be access through browsers

  •                     Web Application
                            Web Services
    •  user to program interaction

    •  program to program interaction

    •  static integration of components

    •  Dynamic integration of components

    •  Monolithic service

    •  service aggregation

    •  ad hoc or proprietary protocol

    •  interoperability






2. Discuss what WSDL is and the use of it in the context of web services 


WSDL: Written in XML, WSDL stands for Web Services Description Language and is used to describe web service. WSDL comprises three parts such as Definitions (usually expressed in XML including both data type definitions), Operations and Service bindings. Operations denote actions for the messages supported by a Web service.
There are 3 parts of WSDL,
  • Definitions - normally declared in XML and include both data type definitions and message definitions.
  • Operations - are used to describe actions for the messages where  used by a Web service.
  • Service bindings - port types to a port. A port is detailed by certain network address with a port type.
WSDL Usage:-

Generally WSDL is using as a combination with SOAP and XML schema to afford web services over the Internet
.

3. Explain the fundamental properties of a WSDL document and the use of WSDL document in web services and client development 

Three fundamental properties in WSDL are,


  • What it is - methods it provides.
  • How it is accessed - data format, protocol details.
  • Where it is located - Network Address (URL) details.


4. Discuss the structure of the WSDL document, explaining the elements in WSDL 














definitions
Contains the definition of one or more services. JDeveloper generates the following attribute declarations for this section:types
Provides information about any complex data types used in the WSDL document. When simple types are used the document does not need to have a types section.
message
An abstract definition of the data being communicated. In the example, the message contains just one part, response, which is of type string, where string is defined by the XML Schema.
operation
An abstract description of the action supported by the service.
portType
An abstract set of operations supported by one or more endpoints.
binding
Describes how the operation is invoked by specifying concrete protocol and data format specifications for the operations and messages.
port
Specifies a single endpoint as an address for the binding, thus defining a single communication endpoint.
service
Specifies the port address(es) of the binding. The service is a collection of network endpoints or ports.


5. Compare the PortType and operation elements in WSDL with the java equivalences  


PortType definition is a set of operation components. In java Operations equivalent to method name and PortType is equivalent to java interface.

v  WSDL Document contains One PortType and multiple operations.
v  PortType hasn't input-output patterns and operations has.
v  PortType has one name and Operations should have different names.


6. Compare and contrast the binding and service elements in WSDL 


service:-Specifies the port address(es) of the binding. The service is a collection of network endpoints or ports.

binding:-Describes how the operation is invoked by specifying concrete protocol and data format specifications for the operations and messages.

  • While binding describes how message transmit over network (GET, POST, PUT..) service describes about the location.
  • Binding not state about address and service does.
  • service work under protocol stated in binding.

7. Explain how SOAP is used with HTTP 


SOAP (abbreviation for Simple Object Access Protocol) is a messaging protocol specification for exchanging structured information in the implementation of web services  in  computer networks. Its purpose is to provide extensibility, neutrality and independence. It uses   XML information set for its message format, and relies on application layer protocols, most often Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.

8. Discuss how SOAP can be used for functional oriented communication?  
  1. As seen from the above SOAP message, the first part of the SOAP message is the envelope element which is used to encapsulate the entire SOAP message.
  2. The next element is the SOAP body which contains the details of the actual message.
  3. Our message contains a web service which has the name of "Guru99WebService".
  4. The "Guru99Webservice" accepts a parameter of the type 'int' and has the name of TutorialID.
Now, the above SOAP message will be passed between the web service and the client application.
You can see how useful the above information is to the client application. The SOAP message tells the client application what is the name of the Web service, and also what parameters it expects and also what is the type of each parameter which is taken by the web service.


9. Explain the structure of SOAP message in message oriented communication, indicating the elements used 

A SOAP message is encoded as an XML document, It consists of an <Envelope> element, which contains an optional <Header> element, and a mandatory <Body> element. The <Fault> element, contained in the <Body>, is used for reporting errors. Those are the elements used is SOAP Message and there is a brief description of them below here.
  1. SOAP envelope :- The SOAP <Envelope> is the main element in all SOAP messages. It has two child elements, an optional <Header>, and a mandatory <Body>. This defines the start and end of the message.
  2. SOAP header :- The SOAP <Header> is an optional sub element of the SOAP envelope. It  has optional attributes of message used in processing the message.
  3. SOAP body :- The SOAP <Body> is a mandatory of the SOAP envelope. It contains XML Data which defines details of the message going to be sent.
  4. SOAP fault :- The SOAP <Fault> is a sub element of the SOAP body, this provides error which is occurred while processing the message.
10. Discuss the importance of the SOAP attachments, explaining the MIME header 
Soap Messages With Attachments represents a multipart message format (that means that message contains some additional files like multimedia files) called a SOAP message package. A SOAP message package is constructed according to the following rules:
  • The SOAP header's Content-Type element must be the multipart/related media type.
  • The SOAP message itself is carried in the root body part of the multipart/related structure, so the type parameter of the multipart/related media header must be text/xml.
  • MIME attachments are referenced inside the SOAP message body using SOAP references.
  • Referenced MIME attachments must contain either a matching Content-ID header or a matching Content-Location header.

The following example shows a SOAP 1.1 message with an attached facsimile image of the signed claim form 




11. Identify different set of frameworks/libraries for SOAP web service development, in different environments (Java, .Net, PHP, etc…) 


Name
Platform
Messaging Model(Destination)



Zend Framework
PHP
Client/Server
XFire became Apache CXF
JAVA
Client/Server
XML Interface for network
Services
JAVA
Server
WSO2 WSF/PHP
PHP
Client/Server
Windows Communication
Foundation
.NET
Client/Server/Asyn
Support

Web Services Invocation
Framework
JAVA
Client
Web services Interoperability
JAVA
Client/Server
Symfony2
PHP
Client/Server
Smart.Framework
PHP
Client/Server
gSOAP
C and C++
Client/server
Duplex/Async
Apache CXF
JAVA
Client/server/Asyn
Support
Apache Axis2
JAVA
Client/server/Asyn
Support
Apache Axis
JAVA/C++
Client/Server
.NET Framework
C#/VB.NET
Client/Server






12. Explain the annotations in JAX-WS, providing examples of their use 


Ø  The @WebService annotation provides a Java class as implementing a Web service or provides a service endpoint interface (SEI) as implementing a web service interface.

Ø  The @WebResult annotation customizes the mapping of a return value to a WSDL part or XML element.


Ø  The @WebParam annotation customizes the mapping of an individual parameter to a web service message part and XML element.

Ø  The @HandlerChain annotation associates the web service with an externally defined handler chain.


Ø  The @SOAPBinding annotation specifies the mapping of the web service onto the SOAP message protocol.

Ø  The @WebMethod annotation denotes a method that is a web service operation. Apply this annotation to methods on a client or server Service Endpoint Interface (SEI) or a server endpoint implementation class.


Ø  The @Oneway annotation denotes a method as a web service one-way operation that only has an input message and no output message.


13. Discuss how a web service can be tested using different approaches (using a dummy client or a dedicated tool, etc…)

we have large number of tools to test web services.It is very easier than using a dummy client. If we want to use a dummy to test our web service we can use www.mock-server.com

Tools:-

  • SoapUI is an open source, cross-platform testing tool.
  • TestingWhiz is a codeless test automation tool which comes with API/web services testing capability.
  • SOAPSonar provides comprehensive web services testing for HTML, XML, SOAP, REST, and JSON.
  • SOAtest is an enterprise-grade tool by Parasoft for testing and validating APIs and API-driven apps.
  • TestMaker is an open source tool to test and monitor performance of web, web services and SOA application by PushtoTest.
  • Postman is yet another API/ web services testing tool which comes with powerful HTTP client support.
  • vRest is a tool exclusive for testing, mocking, and validation of REST APIS and web services.
  • HttpMaster is another exclusive tool for REST web services testing.



References

Q1
Q2

Q3


Q4



Q5


Q6




Q7 



Q8







  • Q9

  • No comments:

    Post a Comment

    Tutorial 10 – Client-side development 2 - RiWAs

    PROGRAMMING APPLICATIONS AND FRAMEWORKS                                                  Tutorial 10 Distinguish the term “Rich Internet...