Created
March 29, 2012 19:57
-
-
Save pkmishra/2243055 to your computer and use it in GitHub Desktop.
PHP SOAP client to handle mtom message encoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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