Categories: TutorialWSDL

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>

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
Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

2 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

2 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

2 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

2 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

2 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

2 years ago