From db606bc7a0cb7274b022654af74c4856c58563dc Mon Sep 17 00:00:00 2001 From: isuru Date: Fri, 3 Oct 2014 16:39:02 +0530 Subject: [PATCH 1/2] Add Basic auth to read from config.yml file Add Basic auth to read from config.yml file you can view example from src\BeSimple\SoapBundle\Resources\doc\soapclient\configuration.rst line #18 onwards --- .../DependencyInjection/BeSimpleSoapExtension.php | 7 +++++++ .../DependencyInjection/Configuration.php | 13 +++++++++++++ .../Resources/doc/soapclient/configuration.rst | 5 +++++ 3 files changed, 25 insertions(+) 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: From 10a4edf0b72addcdaaa04145387b16ce9f7524d1 Mon Sep 17 00:00:00 2001 From: isuru Date: Sat, 4 Oct 2014 13:47:33 +0530 Subject: [PATCH 2/2] Fix for multipart soap response Fix for multipart soap response now this will handle soap response like this --uuid:a75a88ed-7f52-4e16-9e52-ad03e9b365e1 Content-Type: application/xop+xml; charset=UTF-8; type="text/xml" Content-Transfer-Encoding: binary Content-ID: 1.0 --uuid:a75a88ed-7f52-4e16-9e52-ad03e9b365e1-- --- src/BeSimple/SoapClient/SoapClient.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; + } } /**