views:

8

answers:

0

Hi i am trying to make a phpSoap Client request to server that expects message to be in below format. I have tried may options got it to work to some extent when there is one name spaced Datum

sat_system 10029 [email protected] 987asdfghbv5633 2009-11-22T11:04:30.000Z sat_system FirstName xxxxxxxx 2009-12-09T11:04:30.000Z sat_system LastName xxxxxxxx 2009-12-09T11:04:30.000Z sat_system Address xxxxxxxx 2009-12-09T11:04:30.000Z

The problem i have is when there is array of datum objects passed as parameter to new SoapVar() , phpSoap adds "" and looses the namespace assigned to individual dataum elements. I am attaching my code below. Any help is solving this problem is greatly appreciated.

class Profile { public $sourceNameSpace; public $sourceGuid; public $emailAddress; public $msgId; public $timestamp; public $ProfileData;

function __construct($sourceNameSpace,$sourceGuid,$emailAddress,$msgId,$timestamp,$profiledata) {
    $this->sourceNameSpace = $sourceNameSpace;
    $this->sourceGuid = $sourceGuid;
    $this->emailAddress = $emailAddress;
    $this->msgId = $msgId;
    $this->timestamp = $timestamp;
    $this->ProfileData = $profiledata;
}

}

class ProfileData { protected $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; } }

$datum1 = new SoapVar(new datum('sat_name','FirstName','xxxxx',time()),SOAP_ENC_OBJECT,NULL, NULL, 'datum', 'http://www.mysite.com'));

$datum2 = new SoapVar(new datum('sat_name','LastName','xxxxx',time()),SOAP_ENC_OBJECT,NULL, NULL, 'datum', 'http://www.mysite.com'));

$ProfileData = new SoapVar(array($datum1,$datum2),SOAP_ENC_ARRAY,NULL, NULL, 'ProfileData','http://www.mysite.com' ));

$Profile = new Profile(new profile('sat_name',1000,'[email protected],10001,$ProfileData);

$var = new SoapVar($Profile,SOAP_ENC_OBJECT,NULL, NULL, 'Profile', 'http://www.mysite.com'));

$url = 'https://nsd6.com:443/UpdateProfileService.wsdl'; $Client = new SoapClient($url, array('trace'=>1)); $Client->__setSoapHeaders($soap_header); try{ $success = $Client->UpdateProfile($var);

 } catch (SoapFault $fault) {
    echo "REQUEST:\n<pre>" . $Client->__getLastRequest() . "</pre>\n";
 }

Greatly appreciate any help that i can receive in solving this problem.