rsoap
A SOAP client library for Rust with compile-time code generation from WSDL files. The
rsoapworkspace provides a runtime client (rsoap) and a procedural macro (rsoap-macros) that parses a WSDL at compile time and generates typed request/response structs, so SOAP services feel like ordinary Rust APIs.
Workspace
| Crate | Role |
|---|---|
rsoap/ |
Runtime library — SoapClient, SoapOperation trait, envelope/XML parsing, SoapError |
rsoap-macros/ |
Proc-macro crate — WSDL parser → typed struct generation |
examples/ |
Demo — weather service (hand-written SoapOperation impl) |
Quick Start
Add the runtime crate and the derive macro to your Cargo.toml:
[]
= { = "../rsoap" }
= { = "../rsoap-macros" }
= { = "1", = ["full"] }
= { = "1", = ["derive"] }
= "1"
Derive a typed operation from a WSDL at compile time:
use ;
;
async
The macro reads the WSDL, resolves the GetTemperature operation, generates gettemperature::Request and gettemperature::Response with #[serde(rename = "...")] on every field, and implements SoapOperation for the marker struct.
Features
- Compile-time WSDL parsing — no runtime XML schema download, no manual struct definitions.
- Typed request/response — generated structs with
serderename attributes match the XSD element names. maxOccurs="unbounded"— automatically wrapped inVec<T>.- XSD → Rust type mapping —
xs:string→String,xs:int→i32,xs:long→i64,xs:float/xs:double/xs:decimal→f64,xs:boolean→bool,xs:date/xs:dateTime→String. - SOAP 1.1 & 1.2 support — version is per-operation (
const VERSION: SoapVersion) and auto-detected from the WSDL binding namespace. 1.1 usestext/xml+SOAPAction; 1.2 usesapplication/soap+xmlwith the action in the Content-Type parameter, and parses the 1.2 fault structure (<Code><Value>/<Reason><Text>). - Fault detection on any HTTP status — non-2xx responses are still read and checked for a SOAP fault body before reporting
HttpStatus. - Custom headers —
.with_header(name, value)for auth, tracing, etc. - Namespace-prefix tolerant — handles
xs:,xsd:,wsdl:,soap:,wsdlsoap:,env:, and bare tags in WSDLs.
SoapError
Implements From<reqwest::Error> for ergonomic ? propagation.
SoapOperation trait
A hand-written operation can declare a SOAP 1.2 version explicitly:
Build & Test
# Build everything
# Lint (correctness is deny-level — hard failures)
# Run all tests (unit + integration + doc tests)
# Run specific test suites
Configuration
The workspace enforces strict lints at the root Cargo.toml:
[]
= { = "deny" }
= { = "warn" }
= { = "warn" }
= { = "warn" }
= { = "warn" }
[]
= "warn"
= "deny"
unsafe is never allowed. missing_docs is warn-level — doc comments on public items are encouraged.
Limitations
- The macro uses a lightweight XML walker tuned for WSDL — it handles namespace prefixes (
xs:,xsd:,wsdlsoap:,wsdlsoap12:,env:), self-closing tags (<xs:element name="x"/>), and attributes on opening tags. It is not a general XML schema validator: CDATA sections, comments containing tag-like text, or pathological nesting (same-name elements nested inside themselves) may confuse it. Standard WSDLs from SoapUI, WSDL2Java, .NET, and similar tools work correctly. - No MTOM / attachments.
rsoap-macrosreads the WSDL at compile time, so the file path must be valid relative to the crate root where#[derive]is invoked.
License
MIT — see LICENSE.