I'm new to SOAP and trying to connect to a SOAP server using PHP's built-in SoapClient. I am receiving this error for days now and didn't find any solution.
This is for a Linux Server. I've tried to include SoapHeaders with timestamps and add different parameters to the request, but still have not succeeded.
This is my code:
$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;
}
I expect a response from the server, but receive this error code instead:
No id attribute on element http://schemas.xmlsoap.org/soap/envelope/:Body
Edit:
Code wsse:InvalidSecurity