我试图从 PHP SoapServer 返回一个 SoapFault,但我坚持创建正确的响应格式。
处理异常时,我返回:
$detail = "message";
return new SoapFault("Client", "ValidationException", null, $detail, "ValidationException");
响应如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>ValidationException</faultstring>
<detail>
<ValidationException>
<message>message</message>
</ValidationException>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
但是,我希望响应看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>ValidationException</faultstring>
<detail>
<ns2:ValidationException xmlns:ns2="http://service.applicationsnet.com/soap/">
<message>message</message>
</ns2:ValidationException>
</detail>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
我尝试了几件事,但没有成功。你能帮我么?
命名空间的另一件事是,是否可以更改“SOAP-ENV”信封命名空间?谢谢。