Java Login

About javalogin.com

Hello guys,
javalogin.com is for Java and J2EE developers, all examples are simple and easy to understand 

It is developed and maintained by Vaibhav Sharma. The views expressed on this website are his own and do not necessarily reflect the views of his former, current or future employers. I am professional Web development. I work for an IT company as Senior Consultant. Primary I write about spring, hibernate and web-services. I am trying to present here new technologies.


     << Previous
Next >>     


WSDL (Web Service Description Language)

Web Services are xml based independent and self descriptive application components that are used to communicate with open protocols. The core of Web Services is a combination of XML and HTTP (XML+HTTP), XML is used as a common language for communication in between different platforms and programming languages and HTTP is commonly used protocol that is used to transfer data between client and server. Most effective reason behind the evaluation of Web Services is its platform and language independent nature, because of using xml as a communicative languages web services enables the developer to expose application functionality across the world without being worried about language or platform changes.
Web Services can be exposed in different platforms, most commonly used platform components are listed below.

  • SOAP
  • UDDI
  • WSDL

Assuming the service provides a single publicly available function, called sayHello. This function expects a single string parameter and returns a single string greeting. For example if you pass the parameter world then service function sayHello returns the greeting, "Hello, world!".

Sample.wsdl
<definitions name="HelloService"
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<message name="SayHelloRequest">
<part name="firstName" type="xsd:string"/>
</message>
<message name="SayHelloResponse">
<part name="greeting" type="xsd:string"/>
</message>

<portType name="Hello_PortType">
<operation name="sayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>

<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>
<service name="Hello_Service">
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address location="http://www.examples.com/SayHello/"/>
</port>
</service>
</definitions>

Here I have used some tags in WSDL. Let's discuss about these tags.

  • Definitions-The targetNamespace in the <wsdl:definitions> element creates a namespace for all the elements that you define in the WSDL document (messages, portTypes, bindings, services, and ports). Although the attribute is optional, you should always create a namespace.
    The <wsdl:definitions> targetNamespace does not in any way restrict imports of other WSDL files. In fact, if you plan to import other WSDL files, its more important to create a targetNamespace to allow you to distinguish between the imported WSDL elements and those created in the WSDL file. When you import a WSDL file, you also import that file's namespace -- which should be different from the targetNamespace.
  • Message- The message describes the data being exchanged between the web services' provider and consumer and each web service has two messages:
    1) input: parameters of the web service
    2) output: return data from the web service
    Each message has zero or more part parameters (one for each parameter of the web service's function) Each part parameter associates with a concrete type defined in the types container element.
  • PortType- The WSDL portType element defines a group of operations, also known as an interface in most environments. Each operation element contains a combination of input and output elements, and when you have an output element you can also have a fault element.
  • Binding- Binding tag is used for how web-service accept these values in request and return response. Binding element describes the concrete details of using a particular portType with a given protocol. The WSDL binding element describes the concrete details of using a particular portType with a given protocol. The binding element contains several extensibility elements as well as a WSDL operation element for each operation in the portType it's describing.
  • Service- The WSDL service element defines a collection of ports, or endpoints, that expose a particular binding. This tag use to just list of port
  • PortType- PortType tage is used to define class name in wsdl. portType can combine one request and one response message into a single request/response operation. This is most commonly used in SOAP services. A portType can define multiple operations.
  • Input- Input tag is used to define input parameter from WSDL.
  • Output- Output tag is used to define output parameter from WSDL.
  • 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.

     << Previous
Next >>