protected function request($method, $url, $body = null, $headers = null)
{
if ($body instanceof DOMDocument) {
$body = $body->saveXML();
}
try {
$this->response = $this->client->createRequest($method, $url, $headers, $body)->send();
} catch (ClientErrorResponseException $e) {
if (!$this->capture_error_responses) {
throw $e;
}
$this->response = $e->getResponse();
} catch (ServerErrorResponseException $e) {
if (!$this->capture_error_responses) {
throw $e;
}
$this->response = $e->getResponse();
}
if (strpos($this->response->getContentType(), 'xml') !== false) {
$this->doc = new DOMDocument();
$this->doc->loadXML($this->response->getBody(true));
if (static::$schema) {
$this->assertTrue($this->doc->schemaValidate(Yii::app()->getBasePath() . '/' . static::$schema));
}
}
}