I'm trying to use PHP Soap but am really struggling. I can build and send the following via cURL but have no idea how to build using SoapClient.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:auc="http://xxxxxxx.com/APOnline" xmlns:get="http://xxxxxxx.com/APOnline/GMData">
<soapenv:Header/>
<soapenv:Body>
<auc:GMData>
<!--Optional:-->
<auc:args>
<get:Authentication>
<auc:PartnerId>XXXXXXX</auc:PartnerId>
<auc:UserName>XXXXXXX</auc:UserName>
<auc:Password>XXXXXXX</auc:Password>
</get:Authentication>
<get:ProjectIdentification>
<!--Optional:-->
<auc:Organization></auc:Organization>
<!--Optional:-->
<auc:Project></auc:Project>
<!--Optional:-->
<auc:ProjectId>1111111</auc:ProjectId>
</get:ProjectIdentification>
<get:Timestamp>0</get:Timestamp>
</auc:args>
</auc:GMData>
</soapenv:Body>
</soapenv:Envelope>
I need to get it back as an array so I can loop through data. Any help on how to build this with SoapVars or just complex arrays would save me days. From what I see, I can't send authentication via headers so that's where I start getting stuck.
Lastly, in my cURL I pass the following headers:
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: http://xxxxxxxx.com/APOnline/GMData",
"Content-length: ".strlen($postXML),
);
I've tried:
$soapURL = "https://xxxxxx.com/Webservices/DataExchange?wsdl" ;
$soapParameters = Array('PartnerID' => "xxxx", 'UserName' => "xxxx", 'Password' => "xxxx") ;
$soapFunction = "GMData" ;
$soapClient = new SoapClient($soapURL);
$soapResult = $soapClient->GMData($soapParameters);
var_dump($soapResult);
The error I get is: Fatal error: Fatal error: Uncaught SoapFault exception: [a:InternalServiceFault] Object reference not set to an instance of an object. in /var/www/cron-gg-update.php:35 Stack trace: #0 [internal function]: SoapClient->__call('GMData...', Array) #1 /var/www/cron-gg-update.php(35): SoapClient->GMData(Array) #2 {main} thrown in /var/www/cron-gg-update.php on line 35
Does anyone have sample code I could try? I'm struggling with how to build the array (I think).