The document outlines XML web service standards, including SOAP, WSDL, UDDI, and REST, which facilitate communication between applications over the internet. It provides examples of creating both SOAP and RESTful web services using JAX-WS and JAX-RS, respectively. Additionally, it discusses extending web services with security, reliability, and transaction management features.
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 ratings0% found this document useful (0 votes)
4 views3 pages
Web Services Detailed
The document outlines XML web service standards, including SOAP, WSDL, UDDI, and REST, which facilitate communication between applications over the internet. It provides examples of creating both SOAP and RESTful web services using JAX-WS and JAX-RS, respectively. Additionally, it discusses extending web services with security, reliability, and transaction management features.
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/ 3
Web Services - XML Standards and Implementation
1. XML Web Service Standards
Web services enable communication between different applications over the internet. XML-based web service standards ensure interoperability and consistency.
### Key Standards:
1. **SOAP (Simple Object Access Protocol)**: - A protocol for exchanging structured information. - Uses XML format for request and response. - Example SOAP Message: ```xml <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getWeather xmlns="http://example.com/weather"> <city>New York</city> </getWeather> </soap:Body> </soap:Envelope> ```
2. **WSDL (Web Services Description Language)**:
- XML-based document describing web service methods, input/output formats, and access protocol.
3. **UDDI (Universal Description, Discovery, and Integration)**:
- A directory for registering and discovering web services.
4. **REST (Representational State Transfer)**:
- Uses HTTP methods (GET, POST, PUT, DELETE). - JSON/XML-based communication. - Example REST API call: ``` GET /weather?city=NewYork HTTP/1.1 Host: api.weather.com ``` 2. Creating Web Services Web services can be created using JAX-WS (for SOAP) or JAX-RS (for REST).
### Creating a SOAP Web Service (JAX-WS):
1. Define the service interface: ```java @WebService public interface WeatherService { @WebMethod String getWeather(String city); } ```
2. Implement the service:
```java @WebService(endpointInterface = "com.example.WeatherService") public class WeatherServiceImpl implements WeatherService { public String getWeather(String city) { return "Sunny in " + city; } } ```
3. Publish the service:
```java Endpoint.publish("http://localhost:8080/weather", new WeatherServiceImpl()); ```
### Creating a RESTful Web Service (JAX-RS):
1. Define the REST endpoint: ```java @Path("/weather") public class WeatherService { @GET @Path("/{city}") @Produces(MediaType.TEXT_PLAIN) public String getWeather(@PathParam("city") String city) { return "Sunny in " + city; } } ``` 2. Deploy it in a Java EE container like Tomcat or WildFly.
3. Extending Web Services
Web services can be extended to include security, reliability, and transaction management.
### 1. Security (WS-Security):
- Ensures message integrity and confidentiality. - Example SOAP security header: ```xml <wsse:Security> <wsse:UsernameToken> <wsse:Username>admin</wsse:Username> <wsse:Password>password</wsse:Password> </wsse:UsernameToken> </wsse:Security> ```
### 2. Reliability (WS-ReliableMessaging):
- Ensures messages are delivered in the correct order and without loss.
### 3. Transactions (WS-AtomicTransaction):
- Ensures consistent execution of multiple operations in a transaction.