我在设置AuthenticationSoapHeaderAmadeus e-Power 服务时遇到问题。我正在使用 PHP 内置的 SoapClient。
WSDL: https ://staging-ws.epower.amadeus.com/ws_usitcolours/EpowerService.asmx?WSDL
我为测试事情而制作的基本课程:
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) {
// ...
}
}
}
示例用法:
$client = new \AmadeusSoapClient();
$client->currencyConversion();
收到错误:
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] =>
)
)
)
)
)
无论我是否使用方法设置标题__setSopHeaders或通过__call方法传递它们,它们总是被忽略..任何其他想法如何设置它们?
对不需要身份验证的方法的请求可以正常工作。
