【发布时间】:2015-06-18 12:41:43
【问题描述】:
每当我在我的 PHP 应用程序中抛出 SoapFault 时,HTTP 状态代码都会设置为 HTTP/1.1 500 Internal Service Error。即使我在抛出SoapFault 之前使用http_response_code() 或header() 将状态代码设置为不同的值,也会发生这种情况。抛出SoapFault时有没有办法改变状态码?不应该叫HTTP/1.1 500 Internal Server Error吗?我什至不知道HTTP/1.1 500 Internal Service Error 存在。
我正在使用 SoapUI 来检查来自我的 SoapServer 的回复。
抛出SoapFault 的示例(在SoapServer 对象处理的函数内)
http_response_code(404);
throw new SoapFault('Client', 'The specified item was not found');
示例响应:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>The specified item was not found</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
示例响应标头:
Date Thu, 18 Jun 2015 12:27:23 GMT
Content-Length 299
#status# HTTP/1.1 500 Internal Service Error
Expires Thu, 19 Nov 1981 08:52:00 GMT
Set-Cookie PHPSESSID=kqhubpja05jfcluohbgts8lmk6; path=/
Connection close
Content-Type text/xml; charset=utf-8
Server Apache/2.4.9 (Win64) PHP/5.5.12
X-Powered-By PHP/5.5.12
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
【问题讨论】:
标签: php soap soapserver