2

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);
4

1 回答 1

1

我正在使用相同的客户端。它提供了一个 getError 可用于检查错误。所以在每次通话后检查:

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

当然,您可能想做一些比仅仅回显错误更好的事情,但这就是想法。

于 2014-04-22T14:44:45.253 回答