Hi I am looking for help with phpSoap Client call. Server is exepecting message in the following format.
<upd:Profile>
<satsystem>sys1</satsystem>
<Id>10029</Id>
<email>[email protected]</email>
<msgId>987asdfghbv5633</msgId>
<timestamp>2009-11-22T11:04:30.000Z</timestamp>
<upd:ProfileData>
<upd:datum>
<satsystem>system1</satsystem>
<key>fname</key>
<value>first name</value>
<timestamp>2009-12-09T11:04:30.000Z</timestamp>
</upd:datum>
<upd:datum>
<satsystem>system1</satsystem>
<key>lname</key>
<value>lastname</value>
<timestamp>2009-11-09T11:04:30.000Z</timestamp>
</upd:datum>
</upd:ProfileData>
I have written the code below, which works to large extent, however it does not work completely. The problem i am having is that when there is single datum element. Message xml generated is correct and works well, however when there are multiple datum elements, xml message generated by soap client looses the namespacing.
class Profile {
public $satname;
public $id;
public $emai;
public $msgId;
public $timestamp;
public $ProfileData;
function __construct($satname,$id,$email,$msgId,$timestamp,$profiledata) {
$this->sourceNameSpace = $satname;
$this->id = $id;
$this->email = $email;
$this->msgId = $msgId;
$this->timestamp = $timestamp;
$this->ProfileData = $profiledata;
}
}
class ProfileData {
public $datum; // variable MUST be protected or public!
function __construct($datum){
$this->datum = $datum;
}
}
class datum {
//any data
public $satname;
public $key;
public $value;
public $timestamp;
function __construct($satname,$key,$value,$timestamp){
$this->satname = $satname;
$this->key = $key;
$this->value = $value;
$this->timestamp = $timestamp;
}
}
$ProfileData = new SoapVar(array($datum1,datum2),SOAP_ENC_ARRAY,NULL, NULL, 'ProfileData', "http://www.nsd6.com");
$Profile = new Profile('system1',$userid,$mail,'10001',gmdate('c',time()),$ProfileData);
$var = new SoapVar($Profile,SOAP_ENC_OBJECT,NULL, NULL, 'Profile',"http://www.nsd6.com"));
$url = 'https://nsd6.com/UpdateProfileService.wsdl';
$Client = new SoapClient($url, array('trace'=>1));
$Client->__setSoapHeaders($soap_header);
try{
//$success = $esbClient->__soapCall('UpdateProfile',array($var),array(),$soap_header);
$success = $Client->UpdateProfile($var);
} catch (SoapFault $fault) {
echo "REQUEST:\n<pre>" . $esbClient->__getLastRequest() . "</pre>\n";
}
I haven't been able to get the code working.
Thanks in advance, Appreciate all your help.
Best regards Ravi