A SOAP web service backed by SQLite, demonstrating Mycel's SOAP connector in server mode.
- Exposes a SOAP endpoint on port 8080
- Auto-generates a WSDL document at
/wsdl - Implements
GetUserandCreateUseroperations - Stores data in a local SQLite database
- Validates input with type schemas
# From the repository root
mycel start --config ./examples/soap
# Or with Docker
docker run -v $(pwd)/examples/soap:/etc/mycel -p 8080:8080 ghcr.io/matutetandil/mycelcurl http://localhost:8080/wsdlReturns the auto-generated WSDL describing all registered operations.
curl -X POST http://localhost:8080/ws \
-H 'Content-Type: text/xml; charset=utf-8' \
-H 'SOAPAction: "CreateUser"' \
-d '<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CreateUser xmlns="http://example.com/users">
<Email>john@example.com</Email>
<Name>John Doe</Name>
</CreateUser>
</soap:Body>
</soap:Envelope>'Expected response:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CreateUserResponse xmlns="http://example.com/users">
<id>1</id>
<email>john@example.com</email>
<name>John Doe</name>
</CreateUserResponse>
</soap:Body>
</soap:Envelope>curl -X POST http://localhost:8080/ws \
-H 'Content-Type: text/xml; charset=utf-8' \
-H 'SOAPAction: "GetUser"' \
-d '<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetUser xmlns="http://example.com/users">
<Email>john@example.com</Email>
</GetUser>
</soap:Body>
</soap:Envelope>'For SOAP 1.2, change the connector's soap_version to "1.2" and use the corresponding Content-Type:
curl -X POST http://localhost:8080/ws \
-H 'Content-Type: application/soap+xml; charset=utf-8; action="CreateUser"' \
-d '<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<CreateUser xmlns="http://example.com/users">
<Email>jane@example.com</Email>
<Name>Jane Doe</Name>
</CreateUser>
</soap:Body>
</soap:Envelope>'Note the differences from SOAP 1.1:
- Content-Type is
application/soap+xml(nottext/xml) - The operation is specified via the
actionparameter in Content-Type (noSOAPActionheader) - The envelope namespace is
http://www.w3.org/2003/05/soap-envelope
soap/
├── config.hcl # Service name and version
├── connectors/
│ ├── soap_server.hcl # SOAP endpoint configuration
│ └── database.hcl # SQLite database connection
├── flows/
│ ├── get_user.hcl # GetUser operation
│ └── create_user.hcl # CreateUser operation
├── types/
│ └── user.hcl # User input validation schema
├── data/
│ └── app.db # SQLite database file (created automatically)
└── setup.sql # Initial database schema
- Bridge SOAP to REST: Add a REST connector and forward SOAP operations to REST endpoints
- Add authentication: Use
auth { type = "basic" }on the connector - Switch to PostgreSQL: Change the database connector driver to
"postgres" - See the SOAP connector reference for all options