-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
Q | A |
---|---|
Bug? | no |
New Feature? | yes |
This is a feature request for adding a soap client (extending the one from PHP) which use a HttpClient implementation to send the soap request.
Having this allow to profit of all the debugging offer by the HttplugBundle for Soap requests.
Here is an example of what we have done in a project :
/**
* Wrapper around PHP SoapClient to use a HttpClient instead of php, allow better control over the request.
*/
class SoapClient extends \SoapClient
{
private $httpClient;
public function __construct(HttpClient $httpClient, $wsdl, array $options = [])
{
$this->httpClient = $httpClient;
parent::__construct($wsdl, $options);
}
/**
* {@inheritdoc}
*/
public function __doRequest($body, $location, $action, $version, $one_way = 0)
{
$headers = [
'Content-Type' => sprintf('application/soap+xml; charset=utf-8; action="%s"', $action),
];
if ($version === SOAP_1_1) {
$headers = [
'Content-Type' => 'text/xml; charset=utf-8',
'SOAPAction' => $action,
];
}
try {
$response = $this->httpClient->sendRequest(new Request('POST', $location, $headers, $body));
} catch (HttpException $exception) {
return $exception->getResponse()->getBody()->getContents();
}
return $response->getBody()->getContents();
}
}
sagikazarmark, Nyholm, dlnilsson, fbourigault and FlickTheManual
Metadata
Metadata
Assignees
Labels
No labels