Hello World Example WSDL Document

Following is the WSDL file that is provided to demonstrate a simple WSDL program.

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

Web Service Name : HelloWorldService

This WSDL example contains:
- SOAP Protocol
- Document Literal Binding
- No optional SOAP Header included in WSDL
- SOAP Body
Content of HelloWorldService.wsdl file
<definitions name="HelloWorldService"
   <message name="SayHelloRequest">
      <part name="firstName" type="xsd:string"/>
   <message name="SayHelloResponse">
      <part name="greeting" type="xsd:string"/>

   <portType name="HelloWorld_PortType">
      <operation name="sayHelloWorld">
         <input message="tns:SayHelloRequest"/>
         <output message="tns:SayHelloResponse"/>

   <binding name="HelloWorld_Binding" type="tns:HelloWorld_PortType">
   <soap:binding style="rpc"
   <operation name="sayHelloWorld">
      <soap:operation soapAction="sayHelloWorld"/>

   <service name="HelloWorld_Service">
      <documentation>WSDL File for HelloWorldService</documentation>
      <port binding="tns:HelloWorld_Binding" name="HelloWorld_Port">

Analysis of the Example
1. Definition : HelloWorldService

2. Type : Using built-in data types and they are defined in XMLSchema.

3. Message :
  • sayHelloRequest : firstName parameter
  • sayHelloresponse: greeting return value
4. Port Type: sayHelloWorld operation that consists of a request and response service.

5. Binding: Direction to use the SOAP HTTP transport protocol.

6. Service: Service available at http://www.dineshonjava.com/SayHelloWorld/.

7. Port: Associates the binding with the URI http://www.dineshonjava.com/SayHelloWorld/ where the running service can be accessed.

WSDL Ports

The <portType> element is the most important WSDL element.
It describes a web service, the operations that can be performed, and the messages that are involved.
The <portType> element can be compared to a function library (or a module, or a class) in a traditional programming language.

WSDL Messages

The <message> element defines the data elements of an operation.
Each message can consist of one or more parts. The parts can be compared to the parameters of a function call in a traditional programming language.

WSDL Types

The <types> element defines the data types that are used by the web service.
For maximum platform neutrality, WSDL uses XML Schema syntax to define data types.

WSDL Bindings

The <binding> element defines the data format and protocol for each port type.

Wikipedia for WSDL


<<Previous <<   || Index ||   >>Next >>

No comments:

Post a Comment