Expand description
§soap-server
A WSDL-driven SOAP 1.1/1.2 server library for Rust, built on top of axum. Provide a WSDL file, register async handler closures for each operation, and get a fully spec-compliant SOAP endpoint.
§Features
- SOAP 1.1 and 1.2 — auto-detects version from
Content-Typeand envelope namespace; responds in the same version as the request. - WSDL-driven dispatch — operations are discovered from the WSDL at build time. Registering a handler for an unknown operation is a build-time error.
- WS-Security (UsernameToken) — supports PasswordDigest and PasswordText authentication with nonce replay detection and timestamp freshness checks.
- XSD structural validation — required elements are validated against the WSDL/XSD schema before the handler is called.
§Quick start
use soap_server::{FnHandler, ServerBuilder, SoapFault};
use bytes::Bytes;
#[tokio::main]
async fn main() {
let svc = ServerBuilder::from_wsdl_file("path/to/service.wsdl")
.handler(
"MyOperation",
FnHandler::new(|_body: Bytes| async move {
// Parse body, call business logic, return response XML bytes.
Ok::<Bytes, SoapFault>(Bytes::from(
r#"<MyOperationResponse xmlns="urn:example"/>"#,
))
}),
)
.build()
.expect("WSDL build failed");
let router = svc.into_router();
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap();
axum::serve(listener, router).await.unwrap();
}§WS-Security
Call .auth(|username| { /* return password or None */ }) on the builder.
Operations that require authentication return a Sender fault if the
<wsse:Security> header is missing or invalid. Use .auth_bypass([...]) to
exempt specific operations (e.g. clock-sync operations).
§Multi-WSDL / multi-service
Call SoapService::into_router() on each service and merge the resulting
axum::Router instances — each service mounts at its own path derived from
the WSDL <service><port address> element.
Re-exports§
pub use crate::dispatch::build_dispatch_table;pub use crate::dispatch::DispatchTable;pub use crate::fault::FaultCode;pub use crate::fault::SoapFault;pub use crate::handler::FnHandler;pub use crate::handler::SoapHandler;pub use crate::xml_escape::escape_attr;pub use crate::xml_escape::escape_text;
Modules§
- dispatch
- fault
- SOAP fault types and serialization for SOAP 1.1 and 1.2.
- handler
- xml_
escape - XML character escaping helpers.
Structs§
- File
Wsdl Loader - A WsdlLoader that resolves import locations relative to a base directory on the filesystem. Used automatically when ServerBuilder::from_wsdl_file() is called.
- Rotating
Nonce Cache - Two-bucket rotating nonce cache for WS-Security replay detection.
- Server
Builder - Builder for a SoapService. Accumulates WSDL source, handlers, auth config, and routing.
- Soap
Service - A fully configured SOAP service that can be converted into an axum Router.
Enums§
- Build
Error - Errors that can occur during ServerBuilder::build().
- Wsdl
Error - Error type for WSDL parsing failures.
Traits§
- Wsdl
Loader - Abstracts file/network I/O for loading WSDL files during recursive import resolution.
Functions§
- validate_
username_ token - Validate a WS-Security UsernameToken from a raw
<wsse:Security>XML element.