I'd appreciate some help to identify why this php code fails silently.
try
{
//define connection options, this allows for recording messages sent and received
$options = array('trace' => 1);
$client = new SoapClient("">cloud.eu.sagecrm.com/.../webservice.wsdl", $options);
//username and password for sage (the user has to have web service access enabled)
$login_details = array('username' => '------------',
'password' => 'xxxxxxxxxxxxxx');
//login to sage
$response = $client->logon($login_details);
//create header to send on future requests
$header = "<sessionheader><sessionid>".$response->result->sessionid."</sessionid></sessionheader>";
$session_var = new SoapVar($header, XSD_ANYXML, null, null, null);
$session_header = new SoapHeader('http://tempuri.org/type', 'SessionHeader', $session_var);
//apply header to client
$client->__setSoapHeaders(array($session_header));
echo "b1";
//define lead data (or pull in from elsewhere), this is only some of the fields
//I will go into further detail on the fields in another blog post
$lead_data = array('companyname' => 'company name',
'companyaddress1' => 'address1',
'personfirstname' => 'first name',
'personlastname' => 'last name',
'status' => 'In Progress');
//create soap variable to send
$lead = new SoapVar($lead_data, XSD_ANYTYPE, "lead", "">http://tempuri.org/type");
//send request to sage
$response = $client->add(array('entityname' => 'lead', 'records' => $lead));
//check response
if (isset($response->result->records->crmid))
{
//worked, the lead id can be found in $response->result->records->crmid
echo "ok";
}
else
{
//failed, display
echo "RESPONSE:\n" . $client->__getLastResponse() . "\n";
}
}
catch (Exception $e)
{
//something went wrong, display request and response
echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
echo "RESPONSE:\n" . $client->__getLastResponse() . "\n";
echo $e->getMessage();
}
Thanks.