I'm trying to extract the Soap response's HTTP status code. So for instance i have :
$client = new SoapClient($wsdl);
$client->__setSoapHeaders(
new SoapHeader(
$nameSpace,
'Security',
$secHeaderValue,
true
)
);
// The actual call
$response = $client->Complete($paramswebservice)
So now i'm getting the response headers, this way :
$responseHeaders = $client->__getLastResponseHeaders();
var_dump($responseHeaders);
This is the result of the vardump : a string formatted this way (web browser - page source code)
What i am doing right now to extract the http status code '200' :
/**
* Returns the HTTP Status code of $response
* @param string $response
* @return string
*/
function extract_response_http_code($response) {
$tmp = explode('\n', $response);
$array = explode(' ', $tmp[0]);
return $array[1];
}
I really don't like this solution. I would like a more robust / consistent one. Any suggestions ?
EDIT 1
As asked in the comments :
HTTP/1.1 200 OK Cache-Control: private, max-age=0 Content-Length: 1315 Content-Type: text/xml; charset=utf-8 Server: Microsoft-IIS/8.5 X-Powered-By: ASP.NET Date: Thu, 30 Mar 2017 08:52:15 GMT

print_r($response)instead of Image?