I am trying to write a snippet of PHP to connect to a third party's API via SOAP to enter some data into their database. The API requires me to pass several mandatory fields for every call (username, password, companyid, entitytype) in addition to the mandatory data fields. It also requires me to call the "ValidateEntity" funciton before calling the "CreateEntity" function. Documentation can be found here:
http://wiki.agemni.com/Getting_Started/APIs/Database_API
I have never worked with SOAP before, so I am very new to this. Here is what I have so far:
error_reporting(E_ALL);
ini_set('display_errors', '1');
$client = new SoapClient("http://agemni.com/AgemniWebservices/service1.asmx?WSDL", array('trace'=> true));
$options = array(
'username' => "myuser",
'password' => "mypassword",
'companyid' => myID,
'entitytype' => 2
);
$params = array(
'fname' => "John",
'lname' => "Doe",
'phone' => "859-333-3333",
'zip' => "40332",
'area id' => "12345",
'lead id' => "28222",
'contactdate' => "4/10/2010"
);
$validate = $client->__soapCall("ValidateEntity", array($params), array($options));
$client->__soapCall("CreateEntity", array($params), array($options));
echo "<pre>";
var_dump($client-> __getLastRequestHeaders());
var_dump($client-> __getLastRequest());
var_dump($client-> __getLastResponseHeaders());
var_dump($client-> __getLastResponse());
var_dump($result);
echo "</pre>";
Upon executing this code, I get the following error:
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object hasn't 'objecttype' property in /www/tmp/index-soap.php:24 Stack trace: #0 /www/tmp/index-soap.php(24): SoapClient->__soapCall('ValidateEntity', Array) #1 {main} thrown in /www/stealth/tmp/index-soap.php on line 24
I guess my question is.. am I even going about doing this the right way? I know this is a very broad question, but I appreciate any advice you can give me about making this work. Please let me know if you require more detail.
Thanks!