Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP SOAP client to handle mtom message encoding
/**
* This client extends the ususal SoapClient to handle mtom encoding. Due
* to mtom encoding soap body has test apart from valid xml. This extension
* remove the text and just keeps the response xml.
*/
class MTOMSoapClient extends SoapClient {
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
//if resposnse content type is mtom strip away everything but the xml.
if (strpos($response, "Content-Type: application/xop+xml") !== false) {
//not using stristr function twice because not supported in php 5.2 as shown below
//$response = stristr(stristr($response, "<s:"), "</s:Envelope>", true) . "</s:Envelope>";
$tempstr = stristr($response, "<s:");
$response = substr($tempstr, 0, strpos($tempstr, "</s:Envelope>")) . "</s:Envelope>";
}
//log_message($response);
return $response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.