I'm having issues setting AuthenticationSoapHeader
for Amadeus e-Power services. I'm using PHP's built in SoapClient.
WSDL: https://staging-ws.epower.amadeus.com/ws_usitcolours/EpowerService.asmx?WSDL
Basic class I've made to test things out:
class AmadeusSoapClient
{
private $_client;
private $_config = [
'wsdl' => 'https://staging-ws.epower.amadeus.com/ws_usitcolours/EpowerService.asmx?WSDL',
'namespace' => 'https://epowerv5.amadeus.com.tr/WS',
'auth' => [
'username' => '...',
'password' => '...'
],
'debug' => true
];
// Construct
public function __construct()
{
// Client
$this->_client = new \SoapClient($this->_config['wsdl'], [
'trace' => $this->_config['debug']
]);
// Headers
$headers = [
// Auth
new \SoapHeader($this->_config['namespace'], 'AuthenticationSoapHeader', [
'WSUserName' => $this->_config['auth']['username'],
'WSPassword' => $this->_config['auth']['password']
]),
];
// Set headers
$this->_client->__setSoapHeaders($headers);
}
// Request: CurrencyConversion
public function currencyConversion($fromCurrency = 'BGN', $toCurrency = 'EUR', $amount = 1.00)
{
$method = 'CurrencyConversion';
$params = [
'OTA_CurrencyConversionRQ' => [
'_' => '',
'FromCurrency' => $fromCurrency,
'ToCurrency' => $toCurrency,
'Amount' => $amount,
],
];
try {
return $this->_client->__call($method, [$params]);
} catch (\Exception $e) {
// ...
}
}
}
Sample usage:
$client = new \AmadeusSoapClient();
$client->currencyConversion();
Error received:
stdClass Object
(
[OTA_CurrencyConversionRS] => stdClass Object
(
[Errors] => stdClass Object
(
[Error] => Array
(
[0] => stdClass Object
(
[_] =>
[Type] => EpowerInternalError
[ErrorCode] => EPW.0000
[ShortText] => User Name is required
[Code] => A001
[NodeList] => EPower
[BreakFlow] =>
)
[1] => stdClass Object
(
[_] =>
[Type] => EpowerInternalError
[ErrorCode] => EPW.0000
[ShortText] => Password is required
[Code] => A001
[NodeList] => EPower
[BreakFlow] =>
)
)
)
)
)
No matter if I set headers with __setSopHeaders
or pass them with the __call
method, they are always ignored.. any other ideas how to set them?
Requests for methods that do not require Authentication are working properly.
Interesting thing is that the same request is working with Postman, but not with PHP SoapClient or SoapUI.