1

PHP アプリケーションでをスローするSoapFaultと、HTTP ステータス コードが に設定されHTTP/1.1 500 Internal Service Errorます。http_response_code()これは、を使用して、またはheader()スローする前に、ステータス コードを別のものに設定した場合でも発生しますSoapFault。をスローするときにステータスコードを変更する方法はありません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
4

1 に答える 1