Вопрос

I wrote applications to use the web services of dynamics crm 2011, one in c#, and the other in php. They both work perfectly. They create a new lead in the crm. But sometimes, an error appear when i want to create a lead directly in the crm : "Your subscription has the maximum amount of storage available. For additional storage,..."

My problem is this error is handle with the c# application, but with the php application there are no exception or error thrown.

I use DynamicsCRM class(http://phpmscrm.codeplex.com/) which extends nusaop_client, and the createEntity() method use the call() method from nusoap:

//Create lead
$crmSoap = new DynamicsCRM("$login","$pass");
if ($crmSoap->client->fault) { 
    header('Location: index.php?return=Fault');
}
else{
    $err = $crmSoap->client->getError();
    if ($err)
    { 
        header("Location: index.php?return=Error: $err");
    }
    else {
        $aLead=array();
        $aLead['subject'] = $_POST['topic'];
        $aLead['firstname'] = $_POST['fname'];
        $aLead['lastname'] = $_POST['lname'];
        $aLead['companyname'] = $_POST['company'];
        $aLead['emailaddress1'] = $_POST['email'];
        $result = $crmSoap->createEntity('lead', $aLead);
        header('Location: index.php?return=Lead created');
    }
}

I wanted to know how to catch a error from the call() method:

$result = $crmSoap->createEntity('lead', $aLead);
Это было полезно?

Решение

I am using the same client. It provides a getError that can be used to check for errors. So after each call check:

if ($err= $crmSoap->getError())
    print_r($err)

Of course, you probably want to do something better than just echo the error but that's the idea.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top