我是 SOAP 新手,并尝试使用 PHP 的内置 SoapClient 连接到 SOAP 服务器。我已经收到这个错误好几天了,但没有找到任何解决方案。
这适用于 Linux 服务器。我尝试包含带有时间戳的 SoapHeaders 并向请求添加不同的参数,但仍然没有成功。
这是我的代码:
$params = array(
'X' => array(
'Y' => '0',
'Z' => '1',
'Q' => array(
'W' => array(
'E' => '1'
)
),
'R' => array(
'T' => 3,
'Y' => array(
'U' => 'x',
'I' => 'y'
)
),
'O' => array(
'P' => '2'
)
),
'A' => array(
'S' => array(
'D' => 'H',
'F' => 'J',
'G' => 'K'
)
)
);
$client = new SoapClient( 'https://path-to-wsdl', array( 'trace' => 1 ) );
$timestamp = gmdate("Y-m-d\TH:i:s\Z");
$timestamp_expires = gmdate("Y-m-d\TH:i:s\Z", strtotime( '+1 hour' ) );
$authHeader = new stdClass();
$authHeader->Timestamp->Created = $timestamp;
$authHeader->Timestamp->Expires = $timestamp_expires;
$Headers[] = new SoapHeader('http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', $authHeader,TRUE);
// $client->__setSoapHeaders($Headers);
try
{
$response = $client->SoapFunction( $params );
}
catch( SoapFault $fault )
{
echo 'Request : <br/><xmp>',
$client->__getLastRequest(),
'</xmp><br/><br/> Error Message : <br/>',
$fault->getMessage();
die;
}
我期待来自服务器的响应,但收到此错误代码:
元素上没有 id 属性http://schemas.xmlsoap.org/soap/envelope/:Body
编辑:
代码 wsse:InvalidSecurity
Cats萌萌
Qyouu