0% found this document useful (0 votes)
22 views

4. SOAP - XML Web Services using Java

The document provides an overview of XML web services using Java, highlighting the distinction between SOAP and REST web services. It explains the characteristics of each type, their differences, and includes a practical example of creating a SOAP web service in Java using Netbeans. Additionally, it outlines the steps for project creation, deployment, and testing of the web service.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

4. SOAP - XML Web Services using Java

The document provides an overview of XML web services using Java, highlighting the distinction between SOAP and REST web services. It explains the characteristics of each type, their differences, and includes a practical example of creating a SOAP web service in Java using Netbeans. Additionally, it outlines the steps for project creation, deployment, and testing of the web service.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

| Java XML Web Services 24 |

XML WEB SERVICES USING JAVA

WEB SERVICES
• It is a type of web application which is used to share the message
between client and server (Communication between two devices on a
network)
• Unlike web applications, the main benefit of web service supports the
code reusability. A single web service can be used by different kinds of
applications
• The main component of a web service is the data which is shared
between client and server
• It is a client server application for creating communication between two
devices over network for exchanging data

TYPES OF WEB SERVICES


• Web services come under two categories. They are
1. SOAP Based Services (XML Services)
2. REST Based Services
• Both services are two different ways to connect applications with server-
side data

1
| Java XML Web Services 24 |

1. SOAP Web Services (XML Web Services)


• SOAP stands for Simple Object Access Protocol
• This is XML based protocol for designing and developing web services.
• It is a platform and language independent as it is XML based
• It is an open standard protocol and provides data transport for web
services (Web services use SOAP protocol for sending the XML data
between applications)
2. REST Web Services (RESTful Web Services)
• REST stands for REpresentational State Transfer
• It is an architectural style for developing web services
• It is most popular web services on current trends
• Web services that implement REST architecture are called as RESTful
web services
• It is designed specifically for the components like media components,
files or objects on a particular hardware
DIFFERENCES BETWEEN SOAP AND REST WEB SERVICES
S.N SOAP Services REST Services
1. SOAP stands for simple object REST stands for
access protocol (Structured representational state transfer.
protocol)
2. It is a protocol REST is an architectural style
3. It only supports XML format It supports various formats like
HTML, XML, JSON, Plain Text
etc,.
4. SOAP needs more bandwidth for its REST doesn’t need more
usage bandwidth
5. JAX-WS is the java API for SOAP JAX-RS is the java API for
web services REST
2
| Java XML Web Services 24 |

6. It is more secure than REST It is less secure than SOAP


7. Resources – XML & HTTP Resources – HTTP
8. It is used to transport data in XML Here it is used to transport
format data in JSON format which is
based on URI.
9. As it is XML based, it works with It works with HTTP GET,
WSDL (Web Service Description POST, PUT, DELETE methods
Language)
10. It can’t use REST because it is a REST can use SOAP web
protocol services and it can use any
protocols like HTTP, SOAP
11. It uses service interfaces to expose It uses the URI (Uniform
the business logic Resource Identity) to expose
the business logic
12. It is less preferred than REST It is most preferred than SOAP.
It is most popular web services
on recent days

3
| Java XML Web Services 24 |

I. EXAMPLE OF XML / SOAP WEB SERVICES IN JAVA


IDE used : Netbeans 18
Application Type : Java Web
Server Tested : Glassfish Server 5
Type of Web Services : XML
JDK Version : 1.8
J2EE Version : J2EE 8
Deployment Mode : Server Side Only

STEP 1 – CREATE A NEW PROJECT IN NETBEANS 18

4
| Java XML Web Services 24 |

STEP 2 – DETAILS OF PROJECT NAME & LOCATION

5
| Java XML Web Services 24 |

STEP 3 – SERVER SELECTION

6
| Java XML Web Services 24 |

STEP 4 – FRAMEWORK SELECTION - OPTIONAL

7
| Java XML Web Services 24 |

VERIFICATION OF NEWLY CREATED PROJECT IN NETBEANS

8
| Java XML Web Services 24 |

2. SOURCE CODE
(NewWebService.java)
package tp;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
@WebService(serviceName = "NewWebService")
public class NewWebService
{
@WebMethod(operationName = "hello")
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !";
}
@WebMethod()
public String Add(int a, int b)
{
int c=a+b;
return "Sum is: "+Integer.toString(c);
}
@WebMethod()
public String Sub(int a, int b)
{
int c=a-b;
return "Sub is: "+Integer.toString(c);
}
@WebMethod()
public String Mul(int a, int b)
{
int c=a*b;
9
| Java XML Web Services 24 |

return "Mul is: "+Integer.toString(c);


}
@WebMethod()
public String Div(int a, int b)
{
int c=a/b;
return "Div is: "+Integer.toString(c);
}
}

10
| Java XML Web Services 24 |

3. OUTPUT
3.1 DEPLOYING THE PROJECT BEFORE TESTING THE WEB SERVICE
→ RIGHT CLICK ON THE CURRENT PROJECT AND SELECT DEPLOY
OPTION

11
| Java XML Web Services 24 |

3.2 DEPLOYED RESULT IN NETBEANS TERMINAL

12
| Java XML Web Services 24 |

3.3 DEPLOYED RESULT IN GLASSFISH SERVER

13
| Java XML Web Services 24 |

3.4 DEPLOYED RESULT IN GLASSFISH SERVER – (Continue)

14
| Java XML Web Services 24 |

3.5 RUNNING THE WEB SERVICE

15
| Java XML Web Services 24 |

3.6 HOME PAGE OF WEB SERVICE – LIST OF AVAILABLE SERVICES

16
| Java XML Web Services 24 |

3.7 TESTING WEB SERVICES – ADD WEB METHOD – SUBMISSION OF


DYNAMIC INPUTS

17
| Java XML Web Services 24 |

3.8 RESULT – XML INTERFACE

18
| Java XML Web Services 24 |

3.9 RESULT – XML – SOAP REQUEST & SOAP RESPONSE

19

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy