Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Basic auth to read from config.yml file #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
13 changes: 13 additions & 0 deletions src/BeSimple/SoapBundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion src/BeSimple/SoapClient/SoapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("</soap:Envelope>",stristr($response,"<soap:Envelope"));
return $response[0] . "</soap:Envelope>";
}
else{
return $response;
}
}

/**
Expand Down