SOAP测试
SOAP请求模板生成,支持SOAP 1.1/1.2和WS-Security
🔧 请求生成
📋 请求模板
📖 参考文档
SOAP 1.1 基础请求
POST /service HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/GetUser"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetUser xmlns="http://tempuri.org/">
<userId>123</userId>
</GetUser>
</soap:Body>
</soap:Envelope>SOAP 1.2 基础请求
POST /service HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetUser xmlns="http://tempuri.org/">
<userId>123</userId>
</GetUser>
</soap12:Body>
</soap12:Envelope>带WS-Security的请求
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>admin</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>...</soap:Body>
</soap:Envelope>SOAP Fault 响应
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Internal Server Error</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>cURL 发送SOAP请求
curl -X POST https://example.com/soap/service \ -H "Content-Type: text/xml; charset=utf-8" \ -H 'SOAPAction: "http://tempuri.org/GetUser"' \ -d '<?xml version="1.0"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetUser xmlns="http://tempuri.org/"><userId>123</userId></GetUser></soap:Body></soap:Envelope>'
SOAP 1.1 vs 1.2 区别
SOAP 1.1: Content-Type: text/xml 需要 SOAPAction 头 命名空间: http://schemas.xmlsoap.org/soap/envelope/ SOAP 1.2: Content-Type: application/soap+xml SOAPAction 可选(在Content-Type中) 命名空间: http://www.w3.org/2003/05/soap-envelope