我们在设置PHP SOAP客户端以使用Royal Mail Tracking API时遇到了一些问题.我们有一个帐户都设有皇家邮政,并有我们的身份证和秘密.我们可以使用SOAPUI来使用它,但是当我尝试在PHP中实现它时,我们总是遇到"错误的版本"错误.我们有本地的WSDL文件(英国皇家邮政通过他们的开发人员门户提供)这一点也适用SOAPUI但不是PHP SOAP客户端.我们希望有人能够看到我们做错了什么.我将发布下面的代码,但会从代码中省略我们的秘密和ID.
<?php
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('soap.wsdl_cache_ttl', 900);
ini_set('default_socket_timeout', 15);
$trackingNumber = 'F111111111JD';
$time = gmdate('Y-m-d\TH:i:s');
$intHeaders = [
'dateTime' => $time,
'version' => '1.0',
'identification' => [
'applicationId' => '***********',
'transactionId' => 123456
]
];
$wsdl = 'WSDL/Tracking_API_V1_1_1.wsdl';
$options = array(
'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
'style'=>SOAP_RPC,
'use'=>SOAP_ENCODED,
'soap_version'=>SOAP_1_2,
'cache_wsdl'=>WSDL_CACHE_NONE,
'connection_timeout'=>15,
'trace'=>true,
'encoding'=>'UTF-8',
'exceptions'=>true,
'stream_context' => stream_context_create([
"http" => [
'Accept' => 'application/soap+xml',
'X-IBM-Client-Secret' => '****',
'X-IBM-Client-Id'=> '****'
]
])
);
try {
$soap = new SoapClient($wsdl, $options);
$data = …
Run Code Online (Sandbox Code Playgroud)