13
« on: February 03, 2017, 04:15:07 PM »
I'm fighting with a web service that is returning a single message packed into a MIME MultiPart message (so I understand it).
So instead of just XML that PHP SOAP can process happily, I'm getting a SoapFault exception: [Client] looks like we got no XML document in.... because there's extra data before and after the XML.
This is what's being returned:
--uuid:80805a48-8715-46db-93f0-781f9ba28317+id=786
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
....
....
</s:Envelope>
--uuid:80805a48-8715-46db-93f0-781f9ba28317+id=786--
So, I'm planning on extending the SoapClient and overloading the __doRequest so I can manipulate the response and remove all the unwanted crap, for a better word.
class extSoapClient 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. <s:Envelope .... </s:Envelope>
return $response;
}
}
The only problem I have is working how to do it.
I'm sure I can use preg_replace() but I haven't a foggiest what regex to create to make the magic happen. It's definitely not my forte.
Can anyone help, please?