Server-Side Development


Server-Side Development

1. Compare and contrast web applications with web services

We can explain web service as a software interface that provides different machines to communicate through a network. Web services uses following open standards to obtain their tasks.
  • XML
  • SOAP
  • WSDL
  • UDDI
Web application is a application users visits using WAN (internet) or LAN. If someone use a browser to access to some kind of application, Generally we call that as a web application. We are using web services when implementing a web application to call some of database calls and other things.

Web Services :-
  1. no GUI.
  2. Used to communicate between application over internet(can be local server).
  3. platform independent since they use open protocols.
  4. Can be accessed by HTTP methods - GET, POST, PUT, DELETE.
  5. E.g. Google maps API is a web service that used to view map on other sites.
Web applications :-
  1. This has a GUI to interact.
  2. use by end-users.
  3. cross platform and should operate by browsers.
  4. Can be accessed by using GUI.
  5. E.g. facebook.com is a web app includes bunch of web pages.

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

Web Services Description Language (WSDL) is the way of representing a web service interface and it describes a service and how it is going to interact with specific network address.

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. If a client program connected to a web service, it can read the WSDL to check what kind of functions are available on the server. Any special datatypes used are embedded in the WSDL file in the form of XML Schema. The client can then use SOAP to actually call one of the functions listed in the WSDL.


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

There are three fundamental properties in WSDL. Those are,
  • What it is - methods it provides.
  • How it is accessed - data format, protocol details.
  • Where it is located - Network Address (URL) details.
As I previously states WSDL Document provides a brief idea to client about what kind of services available. Therefore client can use those services to use in his/ her development.

4. Structure of the WSDL document, explaining the elements in WSDL

Below diagram represents how the elements are represented in WSDL Document.


Here is the sample code of the client WSDL Document,
<?xml version = '1.0' encoding = 'UTF-8'?>
<!--Generated by the Oracle JDeveloper 10g Web Services WSDL Generator-->
<!--Date Created: Tue Aug 17 10:44:49 BST 2004-->
<definitions
   name="MyJavaClass1WS"
   targetNamespace="http://mypackage/JavaClass1.wsdl"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="http://mypackage/JavaClass1.wsdl"
   xmlns:ns1="http://mypackage/IMyJavaClass1WS.xsd">
   <types>
      <schema
         targetNamespace="http://mypackage/IMyJavaClass1WS.xsd"
         xmlns="http://www.w3.org/2001/XMLSchema"
         xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"/>
   </types>
   <message name="getDate0Request"/>
   <message name="getDate0Response">
      <part name="return" type="xsd:string"/>
   </message>
   <portType name="JavaClass1PortType">
      <operation name="getDate">
         <input name="getDate0Request" message="tns:getDate0Request"/>
         <output name="getDate0Response" message="tns:getDate0Response"/>
      </operation>
   </portType>
   <binding name="JavaClass1Binding" type="tns:JavaClass1PortType">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="getDate">
         <soap:operation soapAction="" style="rpc"/>
         <input name="getDate0Request">
            <soap:body use="encoded" namespace="MyJavaClass1WS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
         </input>
         <output name="getDate0Response">
            <soap:body use="encoded" namespace="MyJavaClass1WS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
         </output>
      </operation>
   </binding>
   <service name="MyJavaClass1WS">
      <port name="JavaClass1Port" binding="tns:JavaClass1Binding">
         <soap:address location="http://UKP16211:8888/Application1-Project-context-root/MyJavaClass1WS"/>
      </port>
   </service>
</definitions
Here are the Major Elements in WSDL Document,
  • types, data type definitions which describes the messages.
  • message, Describes a brief definition of the data going to be communicate. 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.

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.
  • WSDL Document contains One PortType and multiple operations.
  • PortType hasn't input-output patterns and operations has.
  • PortType has one name and Operations should have different names.

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

Binding − It is the concrete protocol and data formats for the operations and messages defined for a particular port type.

Service − It is a collection of related end-points encompassing the service definitions in the file; the services map the binding to the port and include any extensibility definitions.
  • 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 ( Simple Object Access Protocol) is a message communication protocol that allows distributed elements of an application to communicate. SOAP can be bring over a vary of lower-level protocols, including the web-related Hypertext Transfer Protocol (HTTP).  SOAP defines a header structure that identifies the actions that various SOAP nodes are expected to take on the message, in addition to a payload structure for carrying information. The concept of routing a message through a string of nodes that perform different functions is how SOAP supports things like addressing, security and format-independence.

8. Discuss how SOAP can be used for functional oriented communication?

All communication by SOAP is done via the HTTP protocol. Prior to SOAP, a lot of web services used the standard RPC (Remote Procedure Call) style for communication. This was the simplest type of communication, but it had a lot of limitations.

Let's consider the below diagram to see how this communication works. In this example, let's assume the server hosts a web service which provided 2 methods as
GetEmployee - This would get all Employee details
SetEmployee – This would set the value of the details like employees dept, salary, etc. accordingly.
In the normal RPC style communication, the client would just call the methods in its request and send the required parameters to the server, and the server would then send the desired response.


9. 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.
With the exception of the <Fault> element, which is contained in the <Body> of a SOAP message, XML elements in the <Header> and the <Body> are defined by the applications that make use of them. However, the SOAP specification imposes some constraints on their structure.


10.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 specification also recommends that the root part contain a Content-ID header, and that the multipart/related media header contain a matching start parameter. This permits more robust error detection.


MIME for web services is the use of web services to send and receive files with a combination of SOAP and MIME, primarily over HTTP.

The web servers insert the MIME header at the beginning of any Web transmission. Clients use this content type or media type header to select an appropriate “player” application for the type of data the header indicates.There is a example of MIME header here below.
    MIME-Version: 1.0
    Content-Type: multipart/related; boundary="MIME_Boundary"; 
       type=text/xml; start="<contacts.xml@someCompany.com>" 
    
    --MIME_Boundary  
    Content-ID: <contacts.xml@someCompany.com>
    Content-Type: text/xml; charset=us-ascii
    
    <SOAP-ENV:Envelope xmlns:SOAP-ENV=
      "http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP-ENV:Body>
        <getName>
          <name>SomeCompany</name>
            ...
          <photo href="cid:logo.gif@someCompany.com"/>
        </getName>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    --MIME_Boundary
    Content-ID: <logo.gif@someCompany.com>
    Content-Type: image/gif
    Content-Transfer-Encoding: base64
    .... base64 encoded gif data
    
    --MIME_Boundary--

11. 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
XML Interface for Network Services Java Server ?
XFire became Apache CXF Java Client/Server
WSO2 WSF/PHP PHP Client/Server
Windows Communication Foundation .NET Client/Server/Asyn support
Web Services Invocation Framework Java Client
Web Services Interoperability Technology Java Client/Server
Symfony2 PHP Client/Server
Smart.Framework PHP Client/Server
Java Web Services Development Pack / GlassFish Java 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. 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 @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.
  • The @WebParam annotation customizes the mapping of an individual parameter to a web service message part and XML element.
  • The @WebResult annotation customizes the mapping of a return value to a WSDL part or 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.

13. Testing web service using different approaches (using a dummy client or a dedicated tool, etc...)

There are large number of tools to test web services easily. It is very easier than using a dummy client. if you want to use a dummy client to test yourr web services you can use http://www.mock-server.com/ for that.

Tools:-
Tools which I have mentioned below can be used for testing web services and I will very easy to use. Watch the video herwith attached to take a brief idea how it will be tested.
  1. SoapUI is an open source, cross-platform testing tool.
  2. TestingWhiz is a codeless test automation tool which comes with API/web services testing capability.
  3. SOAPSonar provides comprehensive web services testing for HTML, XML, SOAP, REST, and JSON.
  4. SOAtest is an enterprise-grade tool by Parasoft for testing and validating APIs and API-driven apps.
  5. TestMaker is an open source tool to test and monitor performance of web, web services and SOA application by PushtoTest.
  6. Postman is yet another API/ web services testing tool which comes with powerful HTTP client support.
  7. vRest is a tool exclusive for testing, mocking, and validation of REST APIS and web services.
  8. HttpMaster is another exclusive tool for REST web services testing.

References

[2] Difference Between Web Service and Website - https://www.carmatec.com/blog/web-services-vs-web-applications/
[4] Elements of WSDL Documenthttps://slideplayer.com/slide/4909600/
[9] SOAP Web Services Tutorial: Simple Object Access Protocol EXAMPLEhttps://www.guru99.com/soap-simple-object-access-protocol.html#6

Thank you for reading till the end and will see you soon with another blog post.

Comments

Popular posts from this blog

RiWAs - Client-side development 2

Tutorial 02 – Industry Practices and Tools 1 Article

THE CLIENT-SIDE DEVELOPMENT