Hello,
I am trying to access the GetDiamond method using the php code below and I am getting the following error:
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> You are not authenticated. Please run the Login function first.
Although the Login function is run first. As mentioned in a previous thread
http://technet.rapaport.com/Forum/Developer.aspx?TopicID=2541
Can you please advice what is needed to be added to the code below in order to work ? will the
__setSoapHeaders method work and if so what is the correct code to use it ?
Regards,
Ofer
<?php
$soapClient = new SoapClient("https://technet.rapaport.com/WebServices/RetailFeed/RetailFeed.asmx?wsdl");
// Prepare SoapHeader parameters
$sh_param = array(
'Username' => 'Username',
'Password' => 'Password');
$headers = new SoapHeader('http://soapserver.example.com/webservices', 'UserCredentials', $sh_param);
// Prepare Soap Client
$soapClient->__setSoapHeaders(array($headers));
// Setup the RemoteFunction parameters
$ap_param = array(
'Username' => 'XXXX',
'Password' => 'XXXX');
// Call RemoteFunction ()
$error = 0;
try {
$info = $soapClient->__call("Login", array($ap_param));
print_r($info);
} catch (SoapFault $fault) {
$error = 1;
print("
alert('Sorry, server returned the following ERROR: ".$fault->faultcode."-".$fault->faultstring);
}
if ($error == 0) {
echo "OK";
}
$soapClient = new SoapClient("http://technet.rapaport.com/WebServices/RetailFeed/RetailFeed.asmx?wsdl");
// Setup the RemoteFunction parameters
$ap_param = array(
'Shape' => 'ROUND',
'SizeFrom' => 'double',
'SizeTo' => 'double',
'ColorFrom' => 'D',
'ColorTo' => 'M',
'ClarityFrom' => 'IF',
'ClarityTo' => 'I1',
'CutFrom' => 'EXCELLENT',
'CutTo' => 'FAIR',
'PriceFrom' => 'double',
'PriceTo' => 'double',
'Page' => 'int',
'PageSize' => 'int',
'DiamondsFound' => 'int'
);
// Call RemoteFunction ()
$error = 0;
try {
$info = $soapClient->__call("GetDiamonds", array($ap_param));
} catch (SoapFault $fault) {
$error = 1;
print("
alert('Sorry, server returned the following ERROR: ".$fault->faultcode."-".$fault->faultstring);
}
if ($error == 0) {
echo "OK";
}
?>