0% found this document useful (0 votes)
5 views12 pages

5 Java

The document provides an overview of web services, defining them as standardized software components that enable machine-to-machine communication over the internet using protocols like HTTP and data formats such as XML and JSON. It highlights J2EE's contributions to web service development, including support for both SOAP and REST, and outlines common components used in building web services. Additionally, it presents a use case for a Student Info Service and a Weather API, comparing the features of SOAP and REST protocols.

Uploaded by

Ved Savani
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)
5 views12 pages

5 Java

The document provides an overview of web services, defining them as standardized software components that enable machine-to-machine communication over the internet using protocols like HTTP and data formats such as XML and JSON. It highlights J2EE's contributions to web service development, including support for both SOAP and REST, and outlines common components used in building web services. Additionally, it presents a use case for a Student Info Service and a Weather API, comparing the features of SOAP and REST protocols.

Uploaded by

Ved Savani
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

 Introduction

 Web Service Technology


 J2EE for web service.
 Developing Web Services

2
Definition:
 A Web Service is a standardized software component accessible over the internet
using protocols like HTTP.
 It enables machine-to-machine communication using XML or JSON.

Key Features:
 Platform-independent
 Language-neutral
 Uses open standards (SOAP, WSDL, UDDI, REST)

3
 Achieved via standardized protocols (SOAP/REST) and data formats
(XML/JSON).
 Example: A Java-based service can be consumed by a .NET client using HTTP and
XML.

4
J2EE Contributions:
 Provides APIs and runtime for building scalable, secure web services.
 Supports both SOAP (via JAX-WS) and REST (via JAX-RS).

Common Components:
Component Role
Servlets Handle HTTP requests/responses
JSP Dynamic content generation
EJB Business logic layer
JAX-WS SOAP-based service development
JAX-RS RESTful service development
JNDI, JMS, JDBC Integration and resource access

5
Use Case: Student Info Service
Steps:
1. Define SEI (Service Endpoint Interface):
 @WebService
 public interface StudentService {
 @WebMethod
 String getStudentDetails(String id);
}
6
2. Implement SEI:
 @WebService(endpointInterface =
"[Link]")
 public class StudentServiceImpl implements
StudentService {
 public String getStudentDetails(String id) {
 return "Name: John, ID: " + id;
 }
}
7
3. Deploy to J2EE Server (e.g., GlassFish):
 Package as WAR
 Use WSDL auto-generation

4. Client Access:
 Use SOAP client (e.g., Apache Axis or JAX-WS client)

8
Example: Weather API
Annotations Used:
 @Path, @GET, @POST, @Produces, @Consumes
Sample Code:
@Path("/weather")
public class WeatherService {
@GET
@Path("/{city}")
@Produces(MediaType.APPLICATION_JSON)
public Weather getWeather(@PathParam("city") String city) {
return new Weather(city, 32.5, "Sunny");
} 9
}
Feature SOAP REST
HTTP methods (GET,
Protocol XML over HTTP
POST, etc.)
Data Format XML JSON, XML
Faster (lightweight
Performance Slower (verbose XML)
JSON)
Scalability Less scalable Highly scalable

Security WS-Security HTTPS, OAuth


10
11
12

You might also like