What is Web Service?

Web services are web application components that lets two different applications to communicate over the network.Let if an application which in written java provides web services can be communicated through other languages like PHP,.Net,Python etc.

Web services are powered by XML and two other core technologies: WSDL and SOAP. Before building a Web service, its developers create its definition in the form of a WSDL document that describes the service’s location on the Web and the functionality the service provides.

SOAP

It stands for Simple Object Access Protocol. It is an XML based protocol for exchanging information over the network.It provides a way to communicate between applications running on different operating systems, with different technologies and programming languages.

It provides a simple, standards-based method for sending XML messages between applications. Web services use SOAP to send messages between a service and its client(s).

SOAP messages are XML documents that contain some or all of the following elements:

  • Envelope – It specifies that the XML document is a SOAP message; encloses the message itself.
  • Header (optional) – contains information relevant to the message, e.g., the date the message was sent, authentication data, etc.
  • Body – includes the message payload.
  • Fault (optional) – carries information about a client or server error within a SOAP message

WSDL

It stands for Web Services Description Language.It is an XML-based language for describing Web services.After building our web application we need to expose our web services through various way WSDL is one of them.It is used with SOAP based web services.Through the WSDL, a Web services client learns where a service can be accessed, what operations the service performs, the communication protocols the service supports, and the correct format for sending messages to the service

Structure of WSDL

A WSDL document has a definitions element that contains the other five elements, types, message, portType, binding and service.

  • <definition>:- It contains the definition of one or more services.
  • <types>:- It provides information about complex data types used in the WSDL document.When simple types is used this section doesn’t required.
  • <message>:- It contains service method arguments both input and output.
  • <portType>:- It describes a web service, the operations that can be performed, and the messages that are being used.
  • <binding>:- It defines the data format and protocol for each port type.
  • <service>:- It describes the endpoint of your web service. In other words, the address where the web service can be reached.

WSDL structure for Adder Service.

The service method add receives two integers parameters defined in addRequest and integer as response defined in addResponse.
Web Service can be invoked by http://www.startwithjava.com/addService/ uri as mentioned in service element.

<definitions name="CaculateService" targetNamespace="http://www.examples.com/wsdl/CaculateService.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.startwithjava.com/wsdl/CaculateService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
   <message name="addRequest">
      <part name="num1" type="xsd:int"/>
	   <part name="num2" type="xsd:int"/>
   </message>
	
   <message name="addResponse">
      <part name="sum" type="xsd:int"/>
   </message>

   <portType name="Adder_port">
      <operation name="add">
         <input message="tns:addRequest"/>
         <output message="tns:addResponse"/>
      </operation>
   </portType>

   <binding name="Add_Binding" type="tns:Adder_port">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="add">
         <soap:operation soapAction="add"/>
         <input>
            <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:expertwebindia:addservice" use="encoded"/>
         </input>
		
         <output>
            <soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:expertwebindia:addService" use="encoded"/>
         </output>
      </operation>
   </binding>

   <service name="Adder_Service">
      <documentation>WSDL File for Adder Service</documentation>
      <port binding="tns:Add_Binding" name="Add_Port">
         <soap:address location="http://www.startwithjava.com/addService/" />
      </port>
   </service>
</definitions>

4 Replies to “What is Web Service?”

  1. I do not even know how I ended up here, but I thought
    this post was great. I don’t know who you are but certainly you are going to a famous blogger if you are not already 😉
    Cheers!

  2. My brother suggested I would possibly like this blog. He used to
    be totally right. This put up actually made my day.
    You cann’t imagine just how a lot time I had spent for
    this information! Thanks!

Leave a Reply