So I'm trying to use SoapClient in PHP.
I have a class that works for most multiple services I'm working with but I have a problem.
One of services returns errors with HTTP 500 error, after the headers there is body. I know that using SoapUI. But in PHP I allways get an error and empty response.
Here is the response from SoapUI in raw form:
HTTP/1.1 500 Internal Server Error
Server: nginx/1.4.3
Date: Thu, 13 Mar 2014 10:17:49 GMT
Content-Type: multipart/related;start="<rootpart*e3413bc7-fd66-4420-8d19-c241a5e56173@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:e3413bc7-fd66-4420-8d19-c241a5e56173";start-info="text/xml"
Content-Length: 706
Connection: keep-alive
--uuid:e3413bc7-fd66-4420-8d19-c241a5e56173
Content-Id: <rootpart*e3413bc7-fd66-4420-8d19-c241a5e56173@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope" xmlns=""><faultcode>S:Server</faultcode>
<faultstring>Validation error</faultstring>
<detail><ns2:WsException xmlns:ns2="http://api.system.bacca.pl/">
<error>Kwota pożyczki netto nie może przekroczyć 5000zł</error>
</ns2:WsException></detail></S:Fault></S:Body></S:Envelope>
--uuid:e3413bc7-fd66-4420-8d19-c241a5e56173--
I have extended SoapClient to be able to work with singlepart multipart messages from Soap and here is the code:
class AdvancedSoapClient extends \SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
// strip away everything but the xml.
//http://www.w3.org/TR/soap12-mtom/#xop-serialization - strip mime multipart in onepart responses
$resp = preg_replace('#^.*(<\?xml.*>)[^>]*$#s', '$1', $response);
if($resp == null) {
$xml = stripos($response, '<?xml');
$resp = substr($response, $xml);
$xmlEnd = stripos($resp, 'Envelope>');
$resp = substr($resp,0,$xmlEnd+9);
return $resp;
}
return $resp;
}
}
I've tried to get content in this function but when problem occures $response
is null...
Any ideas what I can do to retrive this response body?
@Edit: All I get from PHP is SoapFault exception:
message: Internal Server Error code: HTTP
@Edit2: Getting complete Raw response (headers & body) would be helpful enough too