12 Commits

Author SHA1 Message Date
e4cb612aed Created a client classmap even when it is empty 2014-04-30 10:54:07 +02:00
59ea6b1ce0 Merge pull request #33 from borissamardzija/master
Update Curl class to support CURLOPT_CAINFO and CURLOPT_CAPATH options
2014-04-25 13:36:04 +02:00
7bb849e394 Update Curl class to support CURLOPT_CAINFO and CURLOPT_CAPATH options 2014-04-25 11:16:34 +02:00
02722eae8f Merge pull request #32 from mremi/filter-request-headers
Added method to tweak HTTP headers of request
2014-04-24 17:22:00 +02:00
b7581f29b0 Removed reference to return an array of HTTP headers 2014-04-24 09:29:58 +02:00
dc6e1e0889 Merge pull request #31 from mremi/http-auth
Added extra option to configure HTTP authentication
2014-04-24 08:38:03 +02:00
f986400dc2 Merge pull request #30 from mremi/method-visibility
Updated visibility from private to protected
2014-04-24 08:36:23 +02:00
67410805ba Added method to tweak HTTP headers of request 2014-04-22 22:29:11 +02:00
2ae7515294 Added extra option to configure HTTP authentication 2014-04-22 22:05:04 +02:00
cdfc3cd5bd Updated visibility from private to protected 2014-04-22 21:53:14 +02:00
9ac755d86e [SoapBundle] Set _format route to xml 2013-12-13 15:25:20 +01:00
321dcf3058 [SoapBundle] Set wsdl request type only if the "wsdl" parameter in present in URL 2013-12-13 11:24:25 +01:00
5 changed files with 41 additions and 16 deletions

View File

@ -95,9 +95,10 @@ class SoapWebServiceController extends ContainerAware
) )
)); ));
$query = $this->container->get('request')->query; $request = $this->container->get('request');
if (!$query->has('wsdl') && !$query->has('WSDL')) { $query = $request->query;
$this->container->get('request')->setRequestFormat('xml'); if ($query->has('wsdl') || $query->has('WSDL')) {
$request->setRequestFormat('wsdl');
} }
return $response; return $response;

View File

@ -104,12 +104,8 @@ class BeSimpleSoapExtension extends Extension
$definition->replaceArgument(1, $defOptions); $definition->replaceArgument(1, $defOptions);
if (!empty($options['classmap'])) {
$classmap = $this->createClientClassmap($client, $options['classmap'], $container); $classmap = $this->createClientClassmap($client, $options['classmap'], $container);
$definition->replaceArgument(2, new Reference($classmap)); $definition->replaceArgument(2, new Reference($classmap));
} else {
$definition->replaceArgument(2, null);
}
$this->createClient($client, $container); $this->createClient($client, $container);
} }
@ -120,9 +116,11 @@ class BeSimpleSoapExtension extends Extension
$definition = new DefinitionDecorator('besimple.soap.classmap'); $definition = new DefinitionDecorator('besimple.soap.classmap');
$container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition); $container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition);
if (!empty($classmap)) {
$definition->setMethodCalls(array( $definition->setMethodCalls(array(
array('set', array($classmap)), array('set', array($classmap)),
)); ));
}
return sprintf('besimple.soap.classmap.%s', $client); return sprintf('besimple.soap.classmap.%s', $client);
} }

View File

@ -6,13 +6,13 @@
<route id="_webservice_call" pattern="/{webservice}"> <route id="_webservice_call" pattern="/{webservice}">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default> <default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
<default key="_format">soap</default> <default key="_format">xml</default>
<requirement key="_method">POST</requirement> <requirement key="_method">POST</requirement>
</route> </route>
<route id="_webservice_definition" pattern="/{webservice}"> <route id="_webservice_definition" pattern="/{webservice}">
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default> <default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
<default key="_format">wsdl</default> <default key="_format">xml</default>
<requirement key="_method">GET</requirement> <requirement key="_method">GET</requirement>
</route> </route>
</routes> </routes>

View File

@ -88,13 +88,19 @@ class Curl
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']); curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']);
} }
if (isset($options['login'])) { if (isset($options['login'])) {
curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($this->ch, CURLOPT_HTTPAUTH, isset($options['extra_options']['http_auth']) ? $options['extra_options']['http_auth'] : CURLAUTH_ANY);
curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']); curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']);
} }
if (isset($options['local_cert'])) { if (isset($options['local_cert'])) {
curl_setopt($this->ch, CURLOPT_SSLCERT, $options['local_cert']); curl_setopt($this->ch, CURLOPT_SSLCERT, $options['local_cert']);
curl_setopt($this->ch, CURLOPT_SSLCERTPASSWD, $options['passphrase']); curl_setopt($this->ch, CURLOPT_SSLCERTPASSWD, $options['passphrase']);
} }
if (isset($options['ca_info'])) {
curl_setopt($this->ch, CURLOPT_CAINFO, $options['ca_info']);
}
if (isset($options['ca_path'])) {
curl_setopt($this->ch, CURLOPT_CAPATH, $options['ca_path']);
}
} }
/** /**

View File

@ -113,6 +113,11 @@ class SoapClient extends \SoapClient
$this->cliWebserverWorkaround = $options['cli_webserver_workaround']; $this->cliWebserverWorkaround = $options['cli_webserver_workaround'];
} }
$this->curl = new Curl($options); $this->curl = new Curl($options);
if (isset($options['extra_options'])) {
unset($options['extra_options']);
}
$wsdlFile = $this->loadWsdl($wsdl, $options); $wsdlFile = $this->loadWsdl($wsdl, $options);
// TODO $wsdlHandler = new WsdlHandler($wsdlFile, $this->soapVersion); // TODO $wsdlHandler = new WsdlHandler($wsdlFile, $this->soapVersion);
$this->soapKernel = new SoapKernel(); $this->soapKernel = new SoapKernel();
@ -173,6 +178,8 @@ class SoapClient extends \SoapClient
$headers = array(); $headers = array();
} }
$headers = $this->filterRequestHeaders($soapRequest, $headers);
// execute HTTP request with cURL // execute HTTP request with cURL
$responseSuccessfull = $this->curl->exec( $responseSuccessfull = $this->curl->exec(
$location, $location,
@ -253,6 +260,19 @@ class SoapClient extends \SoapClient
return $soapResponse; return $soapResponse;
} }
/**
* Filters HTTP headers which will be sent
*
* @param SoapRequest $soapRequest SOAP request object
* @param array $headers An array of HTTP headers
*
* @return array
*/
protected function filterRequestHeaders(SoapRequest $soapRequest, array $headers)
{
return $headers;
}
/** /**
* Get last request HTTP headers. * Get last request HTTP headers.
* *
@ -354,7 +374,7 @@ class SoapClient extends \SoapClient
* *
* @return string * @return string
*/ */
private function loadWsdl($wsdl, array $options) protected function loadWsdl($wsdl, array $options)
{ {
// option to resolve wsdl/xsd includes // option to resolve wsdl/xsd includes
$resolveRemoteIncludes = true; $resolveRemoteIncludes = true;