Files
jaxwsdemo/README.md
Ken Yasue 0322191af8 Initial commit: JAX-WS Hello World Service
- Complete JAX-WS Hello World implementation
- Docker and Docker Compose support for easy deployment
- Python test scripts for service validation
- Comprehensive README with setup instructions for Windows and Linux
- Maven configuration with JAX-WS dependencies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 09:11:38 +01:00

425 lines
9.1 KiB
Markdown

# JAX-WS Hello World Project
A simple JAX-WS web service boilerplate project that returns "Hello World" messages.
## Project Structure
```
jaxws-hello-world/
├── pom.xml
├── src/
│ └── main/
│ ├── java/
│ │ └── com/
│ │ └── example/
│ │ └── service/
│ │ ├── HelloWorldService.java
│ │ └── HelloWorldServiceImpl.java
│ └── webapp/
│ └── WEB-INF/
│ ├── web.xml
│ └── sun-jaxws.xml
```
## Files Overview
- **pom.xml**: Maven configuration with JAX-WS dependencies
- **HelloWorldService.java**: Web service interface with @WebService annotation
- **HelloWorldServiceImpl.java**: Implementation of the web service
- **web.xml**: Web application deployment descriptor
- **sun-jaxws.xml**: JAX-WS endpoint configuration
- **Dockerfile**: Multi-stage Docker build configuration
- **docker-compose.yml**: Docker Compose orchestration file
- **tomcat-users.xml**: Tomcat manager user configuration
## Quick Start with Docker (Recommended)
The easiest way to test this application is using Docker. No need to install Java, Maven, or Tomcat!
### Prerequisites
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) (Windows/Mac/Linux)
- OR [Docker Engine](https://docs.docker.com/engine/install/) (Linux)
### Running with Docker Compose
**1. Start the application:**
```bash
docker-compose up -d
```
**2. Wait for the application to start (about 30-40 seconds), then access:**
- **WSDL**: http://localhost:8080/jaxws-hello-world/services/hello?wsdl
- **Tomcat Manager**: http://localhost:8080/manager (username: `admin`, password: `admin123`)
**3. View logs:**
```bash
docker-compose logs -f
```
**4. Stop the application:**
```bash
docker-compose down
```
### Running with Docker (without Docker Compose)
**1. Build the Docker image:**
```bash
docker build -t jaxws-hello-world .
```
**2. Run the container:**
```bash
docker run -d -p 8080:8080 --name jaxws-service jaxws-hello-world
```
**3. View logs:**
```bash
docker logs -f jaxws-service
```
**4. Stop and remove the container:**
```bash
docker stop jaxws-service
docker rm jaxws-service
```
### Testing the Docker Deployment
Once the container is running, test the service:
```bash
# Check if WSDL is accessible
curl http://localhost:8080/jaxws-hello-world/services/hello?wsdl
# Test with a SOAP request
curl -X POST http://localhost:8080/jaxws-hello-world/services/hello \
-H "Content-Type: text/xml; charset=utf-8" \
-H "SOAPAction: " \
-d '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.example.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:getHelloWorld>
<arg0>Docker</arg0>
</ser:getHelloWorld>
</soapenv:Body>
</soapenv:Envelope>'
```
---
## Environment Setup
### Windows Setup
#### 1. Install Java Development Kit (JDK)
**Option A: Using Installer**
1. Download JDK 8 or higher from [Oracle](https://www.oracle.com/java/technologies/downloads/) or [OpenJDK](https://adoptium.net/)
2. Run the installer (e.g., `jdk-8u351-windows-x64.exe`)
3. Follow the installation wizard
4. Set JAVA_HOME environment variable:
```cmd
setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0_351"
setx PATH "%PATH%;%JAVA_HOME%\bin"
```
**Option B: Using Chocolatey**
```cmd
choco install openjdk
```
**Verify Installation:**
```cmd
java -version
javac -version
```
#### 2. Install Apache Maven
**Option A: Manual Installation**
1. Download Maven from [Apache Maven](https://maven.apache.org/download.cgi)
2. Extract to `C:\Program Files\Apache\maven`
3. Set environment variables:
```cmd
setx MAVEN_HOME "C:\Program Files\Apache\maven"
setx PATH "%PATH%;%MAVEN_HOME%\bin"
```
**Option B: Using Chocolatey**
```cmd
choco install maven
```
**Verify Installation:**
```cmd
mvn -version
```
#### 3. Install Apache Tomcat
**Option A: Manual Installation**
1. Download Tomcat 9+ from [Apache Tomcat](https://tomcat.apache.org/download-90.cgi)
2. Extract to `C:\Program Files\Apache\Tomcat`
3. Set CATALINA_HOME:
```cmd
setx CATALINA_HOME "C:\Program Files\Apache\Tomcat"
```
**Option B: Using Chocolatey**
```cmd
choco install tomcat
```
**Start Tomcat:**
```cmd
cd C:\Program Files\Apache\Tomcat\bin
startup.bat
```
**Stop Tomcat:**
```cmd
cd C:\Program Files\Apache\Tomcat\bin
shutdown.bat
```
#### 4. Configure Tomcat Manager (Optional)
Edit `C:\Program Files\Apache\Tomcat\conf\tomcat-users.xml`:
```xml
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin123" roles="manager-gui,manager-script"/>
</tomcat-users>
```
Access at: `http://localhost:8080/manager`
---
### Linux Setup
#### 1. Install Java Development Kit (JDK)
**Ubuntu/Debian:**
```bash
# Update package index
sudo apt update
# Install OpenJDK 8
sudo apt install openjdk-8-jdk -y
# OR Install OpenJDK 11
sudo apt install openjdk-11-jdk -y
# Set JAVA_HOME
echo 'export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64' >> ~/.bashrc
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bashrc
source ~/.bashrc
```
**RHEL/CentOS/Fedora:**
```bash
# Install OpenJDK 8
sudo yum install java-1.8.0-openjdk-devel -y
# OR Install OpenJDK 11
sudo dnf install java-11-openjdk-devel -y
# Set JAVA_HOME
echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk' >> ~/.bashrc
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bashrc
source ~/.bashrc
```
**Verify Installation:**
```bash
java -version
javac -version
```
#### 2. Install Apache Maven
**Ubuntu/Debian:**
```bash
sudo apt update
sudo apt install maven -y
```
**RHEL/CentOS/Fedora:**
```bash
sudo yum install maven -y
# OR
sudo dnf install maven -y
```
**Manual Installation (All Distributions):**
```bash
# Download Maven
cd /opt
sudo wget https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz
sudo tar xzf apache-maven-3.9.5-bin.tar.gz
sudo ln -s apache-maven-3.9.5 maven
# Set environment variables
echo 'export MAVEN_HOME=/opt/maven' >> ~/.bashrc
echo 'export PATH=$PATH:$MAVEN_HOME/bin' >> ~/.bashrc
source ~/.bashrc
```
**Verify Installation:**
```bash
mvn -version
```
#### 3. Install Apache Tomcat
**Using Package Manager (Ubuntu/Debian):**
```bash
sudo apt update
sudo apt install tomcat9 -y
# Start Tomcat
sudo systemctl start tomcat9
sudo systemctl enable tomcat9
# Check status
sudo systemctl status tomcat9
```
**Manual Installation (All Distributions):**
```bash
# Download Tomcat
cd /opt
sudo wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.80/bin/apache-tomcat-9.0.80.tar.gz
sudo tar xzf apache-tomcat-9.0.80.tar.gz
sudo ln -s apache-tomcat-9.0.80 tomcat
# Set permissions
sudo chmod +x /opt/tomcat/bin/*.sh
# Set environment variable
echo 'export CATALINA_HOME=/opt/tomcat' >> ~/.bashrc
source ~/.bashrc
# Start Tomcat
/opt/tomcat/bin/startup.sh
# Stop Tomcat
/opt/tomcat/bin/shutdown.sh
```
#### 4. Configure Tomcat Manager (Optional)
Edit `/opt/tomcat/conf/tomcat-users.xml` or `/etc/tomcat9/tomcat-users.xml`:
```bash
sudo nano /opt/tomcat/conf/tomcat-users.xml
```
Add:
```xml
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="admin123" roles="manager-gui,manager-script"/>
</tomcat-users>
```
Restart Tomcat:
```bash
# If using systemd
sudo systemctl restart tomcat9
# If manual installation
/opt/tomcat/bin/shutdown.sh
/opt/tomcat/bin/startup.sh
```
Access at: `http://localhost:8080/manager`
---
### Verify Complete Setup
**Check all installations:**
Windows:
```cmd
java -version
javac -version
mvn -version
echo %CATALINA_HOME%
```
Linux:
```bash
java -version
javac -version
mvn -version
echo $CATALINA_HOME
curl http://localhost:8080
```
If all commands return valid output, your environment is ready!
## Building the Project
```bash
mvn clean package
```
This will create a WAR file in the `target/` directory.
## Deploying
Deploy the generated WAR file to a servlet container like:
- Apache Tomcat 9+
- Jetty
- GlassFish
- WildFly
## Testing the Service
Once deployed, the service will be available at:
**WSDL URL**: `http://localhost:8080/jaxws-hello-world/services/hello?wsdl`
**Service Endpoint**: `http://localhost:8080/jaxws-hello-world/services/hello`
### Using SOAP UI or similar tool:
Send a SOAP request like:
```xml
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.example.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:getHelloWorld>
<arg0>World</arg0>
</ser:getHelloWorld>
</soapenv:Body>
</soapenv:Envelope>
```
Response:
```xml
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getHelloWorldResponse xmlns:ns2="http://service.example.com/">
<return>Hello World, World!</return>
</ns2:getHelloWorldResponse>
</soap:Body>
</soap:Envelope>
```
## Requirements
### Option 1: Using Docker (Recommended)
- Docker Desktop or Docker Engine
- Docker Compose (usually included with Docker Desktop)
### Option 2: Traditional Setup
- Java 8 or higher
- Maven 3.6+
- Servlet container (Tomcat 9+, etc.)