Update README with Python test scripts documentation
- Added comprehensive Python testing section - Updated project structure to include scripts folder - Organized Files Overview into categories (Core, Docker, Test Scripts) - Fixed WSDL URLs (removed incorrect /services/ path) - Added examples for both test_hello_world.py and simple_test.py - Included troubleshooting guide for Python tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
144
README.md
144
README.md
@ -7,6 +7,8 @@ A simple JAX-WS web service boilerplate project that returns "Hello World" messa
|
||||
```
|
||||
jaxws-hello-world/
|
||||
├── pom.xml
|
||||
├── Dockerfile
|
||||
├── docker-compose.yml
|
||||
├── src/
|
||||
│ └── main/
|
||||
│ ├── java/
|
||||
@ -19,19 +21,33 @@ jaxws-hello-world/
|
||||
│ └── WEB-INF/
|
||||
│ ├── web.xml
|
||||
│ └── sun-jaxws.xml
|
||||
└── scripts/
|
||||
├── test_hello_world.py
|
||||
├── simple_test.py
|
||||
├── requirements.txt
|
||||
└── README.md
|
||||
```
|
||||
|
||||
## Files Overview
|
||||
|
||||
### Core Files
|
||||
- **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
|
||||
|
||||
### Docker Files
|
||||
- **Dockerfile**: Multi-stage Docker build configuration
|
||||
- **docker-compose.yml**: Docker Compose orchestration file
|
||||
- **tomcat-users.xml**: Tomcat manager user configuration
|
||||
|
||||
### Test Scripts
|
||||
- **scripts/test_hello_world.py**: Interactive Python test client with automated tests
|
||||
- **scripts/simple_test.py**: Simple automated test script for CI/CD
|
||||
- **scripts/requirements.txt**: Python dependencies
|
||||
- **scripts/README.md**: Detailed test script documentation
|
||||
|
||||
## Quick Start with Docker (Recommended)
|
||||
|
||||
The easiest way to test this application is using Docker. No need to install Java, Maven, or Tomcat!
|
||||
@ -48,7 +64,7 @@ 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
|
||||
- **WSDL**: http://localhost:8080/jaxws-hello-world/hello?wsdl
|
||||
- **Tomcat Manager**: http://localhost:8080/manager (username: `admin`, password: `admin123`)
|
||||
|
||||
**3. View logs:**
|
||||
@ -90,10 +106,10 @@ Once the container is running, test the service:
|
||||
|
||||
```bash
|
||||
# Check if WSDL is accessible
|
||||
curl http://localhost:8080/jaxws-hello-world/services/hello?wsdl
|
||||
curl http://localhost:8080/jaxws-hello-world/hello?wsdl
|
||||
|
||||
# Test with a SOAP request
|
||||
curl -X POST http://localhost:8080/jaxws-hello-world/services/hello \
|
||||
curl -X POST http://localhost:8080/jaxws-hello-world/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/">
|
||||
@ -106,6 +122,128 @@ curl -X POST http://localhost:8080/jaxws-hello-world/services/hello \
|
||||
</soapenv:Envelope>'
|
||||
```
|
||||
|
||||
## Testing with Python Scripts
|
||||
|
||||
Python test scripts are provided in the [scripts/](scripts/) folder for easy testing of the JAX-WS service.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Python 3.6 or higher
|
||||
- pip (Python package installer)
|
||||
|
||||
### Setup
|
||||
|
||||
**Install Python dependencies:**
|
||||
|
||||
Windows:
|
||||
```cmd
|
||||
cd scripts
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Linux/Mac:
|
||||
```bash
|
||||
cd scripts
|
||||
pip3 install -r requirements.txt
|
||||
```
|
||||
|
||||
### Available Test Scripts
|
||||
|
||||
#### 1. Simple Test Script
|
||||
|
||||
Quick automated test with a single name:
|
||||
|
||||
```bash
|
||||
# Test with default name "World"
|
||||
python scripts/simple_test.py
|
||||
|
||||
# Test with custom name
|
||||
python scripts/simple_test.py "Your Name"
|
||||
```
|
||||
|
||||
**Example Output:**
|
||||
```
|
||||
Checking service availability...
|
||||
[OK] WSDL is accessible
|
||||
|
||||
Calling service with: 'Your Name'
|
||||
Response: Hello World, Your Name!
|
||||
|
||||
[PASS] Test PASSED!
|
||||
```
|
||||
|
||||
#### 2. Interactive Test Script
|
||||
|
||||
Full-featured test client with automated tests and interactive mode:
|
||||
|
||||
```bash
|
||||
python scripts/test_hello_world.py
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- Checks WSDL availability
|
||||
- Runs automated tests with predefined names
|
||||
- Interactive mode for manual testing
|
||||
- Pretty-prints SOAP requests and responses
|
||||
|
||||
**Example Session:**
|
||||
```
|
||||
============================================================
|
||||
JAX-WS Hello World Service Test Client
|
||||
============================================================
|
||||
|
||||
1. Checking WSDL availability...
|
||||
WSDL is accessible
|
||||
|
||||
2. Testing Hello World Service...
|
||||
|
||||
Calling service with name: 'World'
|
||||
Response: Hello World, World!
|
||||
|
||||
Calling service with name: 'Python Client'
|
||||
Response: Hello World, Python Client!
|
||||
|
||||
3. Interactive Mode
|
||||
--------------------------------------------------------
|
||||
Enter a name (or 'quit' to exit): John
|
||||
Response: Hello World, John!
|
||||
|
||||
Enter a name (or 'quit' to exit): quit
|
||||
```
|
||||
|
||||
### Using the HelloWorldClient Class
|
||||
|
||||
You can also use the `HelloWorldClient` class in your own Python scripts:
|
||||
|
||||
```python
|
||||
from scripts.test_hello_world import HelloWorldClient
|
||||
|
||||
# Create client
|
||||
client = HelloWorldClient()
|
||||
|
||||
# Check service availability
|
||||
is_available, message = client.check_wsdl()
|
||||
print(message)
|
||||
|
||||
# Call the service
|
||||
response = client.call_hello_world("Developer")
|
||||
print(response) # Output: Hello World, Developer!
|
||||
```
|
||||
|
||||
### Troubleshooting Python Tests
|
||||
|
||||
**Service Not Available:**
|
||||
- Ensure Docker container is running: `docker ps | grep jaxws`
|
||||
- Check service URL: `curl http://localhost:8080/jaxws-hello-world/hello?wsdl`
|
||||
|
||||
**Module Not Found:**
|
||||
- Make sure you're in the project root directory
|
||||
- Install dependencies: `pip install -r scripts/requirements.txt`
|
||||
|
||||
**Python Command Not Found:**
|
||||
- Windows: Use `python` or `py`
|
||||
- Linux/Mac: Use `python3`
|
||||
|
||||
---
|
||||
|
||||
## Environment Setup
|
||||
|
||||
Reference in New Issue
Block a user