Soap Web Services

What is web service?

In this article, we will learn about Soap Web services With Examples, Web service is technology to communicate one platform programming language to another programming language. For example, PHP programming language can interact with .net language.

It’s nothing but it gives intercommunication between different programming languages. The communication can be done through a set of XML messages over HTTP protocol.

Types of Web services components

  • SOAP
  • WSDL
  • UDDI

SOAP Component

Soap stands for simple object access protocol. Soap is an XML based protocol for accessing web services. SOAP is a protocol specification for exchanging structured information in the implementation of Web services in computer networks. Soap is W3C recommendation for communication between applications. So it is platform and language independent.

WSDL

WSDL stands for web service description language. It is an XML file where it contains all the information about web services such as method name, method parameter, port and data types. WSDL is XML so it is both human-readable and machine-consumable. Which aids in the ability to call and bind to services dynamically.

WSDL is a part of UDDI. It acts as a middle layer between web service applications.

Components of WSDL

  • Descriptions
  • Types
  • Binding
  • Interface
  • Service
  • Endpoint
  • Message

UDDI

UDDI stands for Universal Description, Discovery and Integration. UDDI is an XML based framework and it is a directory service. UDDI is a directory of web service interfaces described by WSDL, containing information about web services.

Types of web services

SOAP Web services

Soap stands for simple object access protocol. Soap is an XML based protocol for accessing web services. SOAP is a protocol specification for exchanging structured information in the implementation of Web services in computer networks. Soap is a W3C recommendation for communication between applications. So it is platform and language independent.

Web service architecture has two important components

  • Client
  • Service provider

Here we can create a simple hello world application using soap web services in eclipse.

Steps for creating soap web services

1. Create a new dynamic project.

2. Create a new package and name it “com.learning.webservices

3. Create a class HelloWorld

4. Right click on project -> New -> web service

5. In service implantation box, browse HelloWorld class and move both slider to maximum level.Then click finish button.

Advantages of soap Web services

  • Soap provides its own security is known as WS security.
  • It is language and platform independent

Disadvantages of soap web services

  • Soap is slow compared to other web services because soap uses XML format that must be parsed to read. It follows many standards while developing the soap applications.
  • Soap is dependent on WSDL and doesn’t have any mechanism to discover the service.

JAX-WS

JAX- WS application can be developed by two way

  • RPC style
  • Document style

RPC style

RPC style web service use method and parameter to generate XML structure. RPC style is tightly coupled and the message is sent as many elements. It’s difficult to validate generated WSDL against the schema. Soap message keeps the operation name and parameter are sent in discrete value. Below you can see the many message elements in WSDL File.

JAX-WS all API is present in JDK so we don’t need any external jar while developing an application. Let’s create a simple example In RPC style.

Steps to create a JAX-WS RPC style example

1. Create a java project and name it “SoapRPCExample”.

2. Create a package “com.learning.webservices”.

3. In this example, we created 3 java class for server-side and one class for client side.

  • HelloWorld.java
  • HelloWorldImpl.java
  • Publisher.java
  • HelloWorldClient.java

4. Let’s create a server-side Java class

File: HelloWorld.java

This interface is service endpoint interface and we declared style as RPC.We can declare a style as RPC or Document. The only difference between RPC and Document style with respect java coding is change Style.RPC to Style.DOCUMENT

@SOAPBinding(style = Style.DOCUMENT)

File: HelloWorldImpl.java

Here we were given an implementation of the service endpoint.

File: publisher.java

In this class, we written code to generate a WSDL file, for generating a WSDL file we need to run the class and visit the below URL.

 

5. Client-side code is given below

File: HelloWorldClient.java

The output of above code given below

Related Posts :-

Related posts:

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons