Thursday, November 18, 2010

SOAP Interview Questions

What is SOAP?

SOAP, Simple Object Access Protocol is a communication protocol, a way to structure data before transmitting it, is based on XML standard. It is developed to allow communication between applications of different platforms and programming languages via internet.

It can use range of protocols such as HTTP, FTP, SMTP, Post office protocal 3(POP3) to carry documents.

Http-Get, Http-Post works with name/value pair which means transferring complex object is not possible with these protocols, whereas SOAP serializes complex structure, such as ASP.NET DataSets, complex arrays, custom types and XML nodes before transmitting and thus allows exchange of complex objects between applications.

Two components can easily communicate using Remote Procedure Calls protocol. But because of their compatibility and security issues, most of firewalls and proxy server block this type of messages. SOAP uses HTTP channel to transport which makes it widely accepted protocal over the internet.

SOAP and its purpose.

Simple Object Access Protocol is a XML based protocol that enables application to communicate with each other. SOAP has a standard format for sending messages. SOAP allows applications to communicate with each other over http, when different application running on different types of operating systems and using different technologies; SOAP can be used to enable communication between them.

What is SOAP? Explain its purpose.

SOAP is the acronym for Simple Object Access Protocol. XML based messages over a network of computers are exchanged by using SOAP standard, using HTTP.

SOAP purpose:
A web service needs a combination of XML, HTTP and a protocol which is 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.

Give examples where SOAP is used.

  • Different application running on different types of operating systems and using different technologies.
  • Example: 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.

Give examples where SOAP is used.

Remote methods over multiple platforms and technologies are used with HTTP. SOAP is XML based protocol and platform-agnostic. Each application uses different technology. This may cause problems with proxy server and firewalls. SOAP is the solution for this situation.

Industries transport the request for finding best route and best cost price. So the application transfers a request to other similar services which uses SOAP.

What are transport methods in SOAP?

  • Different application running on different types of operating systems and using different technologies.
  • Example: 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.

SOAP request


xmlns:soap=
http://www.w3.org/2001/12/soap-envelope
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">


1234>


SOAP response


xmlns:soap=
http://www.w3.org/2001/12/soap-envelope
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">


ABC
20000


What are Transport methods in SOAP?

Application layer and transport layers of a network are used by SOAP. SMTP and HTTP are the valid application layer protocol uses as transport for SOAP. Wider acceptance is gained by HTTP, as it works better with the current internet infrastructure, especially with firewalls.

Explain the role of XML in SOAP.

XML is used as a message format to communicate. Due to the open source nature of XML, it is widely accepted.

Explain the role of XML in SOAP.

XML is used as the common format for data in cross platform applications. This file is used for representing message for communication. XML is mostly accepted standard for open source applications. XML format is more reliable format for Application Layer protocols for message transmission and negotiation.

What are the elements that should be contained in SOAP message?

  • Envelope – Translates the XML document to a SOAP message. It is the root element.
  • Header – Contains the header message. Contains the application specific information.
  • Body – Contains the call and response message.
  • Fault element – Used for communicating errors. If present, it appears as a child element of the body and can appear only once.

What are the elements that should be contained in SOAP message?

The following are contained in SOAP messages:

- Envelope Element: XML document identification and translation into a SOAP compatible message is done by this element.
-
Header Element: The header message is available in his element
-
Body Element: The call and response message is available in the body element.
-
Fault Element: Errors occurred during the process is handled by fault element.

What is SOAP Envelope element?

SOAP envelope element is the root element used to define the XML document as a SOAP message.

Example:


...
Message information goes here
...

What are SOAP Envelope element, SOAP actor element and SOAP body element?

Envelope Element: Envelope element contains header child and body child element.

Actor Element: Actor element specifies an entity by which an element is processed. It is referred as the ultimate recipient of the message, and used for assigning header entries to specific entities.

Body Element: Body element encloses the body entries of the message.

What is SOAP actor element?

The header element may pass through different endpoints before it reaches the receiver. SOAP actor element is specifically used to address the header element to a specific endpoint.

Syntax:

Soap:actor=”URL”

What is SOAP body element?

SOAP body element is used to enclose the actual message. It is a required element that is enclosed within the Envelope tag.

Example - Request



Apple

What do you mean by SOAP encoding?

A SOAP message has no default encoding. Hence, in order to define data types used in the document encodingStyle attribute is used. It can appear in any SOAP element.

Syntax:

soap:encodingStyle="URI"

What do you mean by SOAP encoding?

XML format is used by SOAP for encoding data. It maps the high level data types into a serialized XML format known as Section 5 encoding (also known as SOAP encoding) and literal encoding. The other type of encoding named Literal encoding uses XML schema to validate information.

What are Web Services?

Answer
Web services exposes functionality over internet using protocol such as HTTP. Web services can be accessed by two disparate applications from different platforms as they use SOAP protocol to expose the business functionality. SOAP is a platform independent protocol, so the consumer of the web services doesn’t have to know any implementation detail of web services based components. This is the reason why web services hosted on windows can even be accessed by LINUX consumer.

  • Web Services can convert your applications into Web-applications.
  • Web services are self-contained and self-describing application components that communicate using open protocols. They can be discovered using Universal Description, Discovery and Integration and be used by other applications.
  • XML + HTTP form the basis of the Web services.

Webservices are designed to support systems interoperability. They interact through standard xml based messages using SOAP. They are sets of codes hosted on a hosting machine which are then accessed by other machines on a network to perform some task. Webservices are defined using WSDL (web services definition language), which exposes the "webmethod" through which they can be accessed. Since webservices are XML based, they are platform independent. Moreoever, even programming language independent. i.e. A java based client request can access a webservice created using .Net technology.

Web Server is a program components that allows us to develop loosely coupled and platform independent application. It enables distributed applications to exchange messages using protocol like HTTP, XML, and SOAP. Since it uses XML based messaging, it enables heterogeneous applications to interoperate with each other.

Define UDDI, DISCO and WSDL.

Answer
UDDI, Universal description, discovery and integration
It is the directory that is used to publish and discover public web services.

DISCO, Discovery
Commonly known as Discovery. Discovery clubs together common services and exposes schema document of the web services.

WSDL, Web Service description language.
This is used to describe web services. The description includes
URL of web services
Method and properties supported by web services
Data type it supports.
Protocol detail it supports.

Describe the process of communication between Client and Web Service.

To communicate with Web Service, Client application creates an object of Web Service Proxy Class. The proxy object provides access to all methods and properties of Web Service to client. The client calls a method on the proxy object. The Web Service infrastructure serializes the method call and arguments into the SOAP message and sends to web service. The web service executes the method and returns the value which gets serialized and send over network. The message then received by client infrastucture, deserializes it and sends to the proxy object. The proxy object returns the value to the client application.

1 comment:

  1. Hi Sshakya,

    I like your post and the way you have explained basics on Soap UI.

    This surely makes it a candidate on my blog which has the best articles and posts across the web.

    Do mail me at aditya_kalra@ymail.com and let me know if it is fine i add this to my blog.

    My blog: http://go-gaga-over-testing.blogspot.com/

    Best Regards,
    Aditya Kalra

    ReplyDelete