diff --git a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php index a0b8c514..15e656a8 100644 --- a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php +++ b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php @@ -97,6 +97,13 @@ private function registerClientConfiguration(array $config, ContainerBuilder $co $defOptions[$key] = $options[$key]; } } + + $auth = $options['auth']; + if((false !== $auth['type']) && ($auth['type'] === 'basic')) { + $definition->addMethodCall('withBasicAuthentication', array( + $auth['login'], $auth['password'] + )); + } $proxy = $options['proxy']; if (false !== $proxy['host']) { diff --git a/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php b/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php index 9374bff2..efdf34d1 100644 --- a/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php +++ b/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php @@ -82,6 +82,19 @@ private function addClientSection(ArrayNodeDefinition $rootNode) ->prototype('array') ->children() ->scalarNode('wsdl')->isRequired()->end() + ->arrayNode('auth') + ->info('auth configuration') + ->addDefaultsIfNotSet() + ->beforeNormalization() + ->ifTrue(function ($v) { return !is_array($v); }) + ->then(function ($v) { return array('type' => null === $v ? false : $v); }) + ->end() + ->children() + ->scalarNode('type')->defaultFalse()->end() + ->scalarNode('login')->defaultNull()->end() + ->scalarNode('password')->defaultNull()->end() + ->end() + ->end() ->scalarNode('user_agent')->end() ->scalarNode('cache_type') ->validate() diff --git a/src/BeSimple/SoapBundle/Resources/doc/soapclient/configuration.rst b/src/BeSimple/SoapBundle/Resources/doc/soapclient/configuration.rst index 59088cce..1a57fdcd 100644 --- a/src/BeSimple/SoapBundle/Resources/doc/soapclient/configuration.rst +++ b/src/BeSimple/SoapBundle/Resources/doc/soapclient/configuration.rst @@ -14,6 +14,11 @@ Configure your first client in your config file: DemoApi: # required wsdl: http://localhost/app_dev.php/ws/DemoApi?wsdl + # (optional) + auth: + type: basic # need to define as basic + login: my_http_auth_username + password: my_http_auth_password # classmap (optional) classmap: diff --git a/src/BeSimple/SoapClient/SoapClient.php b/src/BeSimple/SoapClient/SoapClient.php index 0fa3c7d4..46982340 100644 --- a/src/BeSimple/SoapClient/SoapClient.php +++ b/src/BeSimple/SoapClient/SoapClient.php @@ -208,7 +208,15 @@ public function __doRequest($request, $location, $action, $version, $oneWay = 0) $soapResponse = $this->__doRequest2($soapRequest); // return SOAP response to ext/soap - return $soapResponse->getContent(); + //Fix for php soap multipart message bug + $response = $soapResponse->getContent(); + if (strpos($response ,'uuid') !== false) { + $response = explode("",stristr($response,""; + } + else{ + return $response; + } } /**