I would like to add a person entity through PHP web services and I have some difficulty adding phone and address to this person, can you please let me know what is wrong with my code:
//get WSDL client
$options = array('trace' => true);
$wsdl = 'crm.xxxxx.com/.../CRMwebservice.wsdl';
$client = new SoapClient($wsdl, $options);
//logon
$logonParams = array('username' => 'xxxxxx', 'password' => 'xxxxxx');
$logonResponse = $client->logon($logonParams);
//set swap header
$sessionId = $logonResponse->result->sessionid;
$header = '<sessionheader><sessionid>' . $sessionId . '</sessionid></sessionheader>';
$sessionVar = new SoapVar($header, XSD_ANYXML, null, null, null);
$sessionHeader = new SoapHeader('http://tempuri.org/type', 'SessionHeader', $sessionVar);
$client->__setSoapHeaders(array($sessionHeader));
//add contact/person record
$phoneData[] = array(
'countrycode' => '999',
'areacode' => '99',
'number' => '9999999',
'type' => 'Business',
);
$phone = new SoapVar($phoneData, XSD_ANYTYPE, "phone", "">http://tempuri.org/type");
$emailData[] = array(
'type' => 'Business',
'emailaddress' => '[email protected]'
);
$email = new SoapVar($emailData, XSD_ANYTYPE, "email", "">http://tempuri.org/type");
$personData = array(
'firstname' => 'firstname',
'lastname' => 'lastname',
'phone' => $phone,
'email' => $email,
'companyname' => 'company',
'country' => 'jordan',
'title' => 'Mr',
'source' => 'web'
);
$person = new SoapVar($personData, SOAP_ENC_OBJECT, "person", "">http://tempuri.org/type");
$personResponse = $client->add(array('entityname' => 'person', 'records' => $person));
$logoffParams = array('sessionId' => $sessionId);
$logoffResponse = $client->logoff($logoffParams);
As you see from the above code I was able to insert a person but the phone & email are empty.