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"
   targetNamespace="https://www.dineshonjava.com/wsdl/HelloWorldService.wsdl"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="https://www.dineshonjava.com/wsdl/HelloWorldService.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="HelloWorld_PortType">
      <operation name="sayHelloWorld">
         <input message="tns:SayHelloRequest"/>
         <output message="tns:SayHelloResponse"/>
      </operation>
   </portType>

   <binding name="HelloWorld_Binding" type="tns:HelloWorld_PortType">
   <soap:binding style="rpc"
      transport="http://schemas.xmlsoap.org/soap/http"/>
   <operation name="sayHelloWorld">
      <soap:operation soapAction="sayHelloWorld"/>
      <input>
         <soap:body
            encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            namespace="urn:examples:helloworldservice"
            use="encoded"/>
      </input>
      <output>
         <soap:body
            encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            namespace="urn:dineshonjava:helloworldservice"
            use="encoded"/>
      </output>
   </operation>
   </binding>

   <service name="HelloWorld_Service">
      <documentation>WSDL File for HelloWorldService</documentation>
      <port binding="tns:HelloWorld_Binding" name="HelloWorld_Port">
         <soap:address
            location="https://www.dineshonjava.com/SayHelloWorld/">
      </port>
   </service>
</definitions>
Hello World Example WSDL Document

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 https://www.dineshonjava.com/SayHelloWorld/.

7. Port: Associates the binding with the URI https://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.

References
Wikipedia for WSDL

 

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