Thursday 5 November 2020

Associative array key becomes param in XML when passed to SoapClient

I have an associative array:

$params = [
  'trid' => null,
  'merchantCode' => null,
  'paymentMethod' => null,
  'returnUrl' => site_url(null),
  'notificationUrl' => site_url(null),
  'language' => 'null',
  'currency' => 'null',
  'isTestMode' => false,
  'productsXml' => null,
  'needInvoice' => true,

(Nulls hold actual values in reality)

When I check __getLastRequest I completly lose the keys in the generated XML.

SoapClient,

    $soap = new SoapClient(null, $options);
    $soap->__soapCall('Request', $params);
    $request = $soap->__getLastRequest();

Please note that I have a NON WSDL connection to the endpoint.

The generated XML will have a field value of <param[keyNum] xsi:type="xsd:typeOfVariable"> instead of having the actual key value from the associative array, <trid> for example.

<SOAP-ENV:Body><ns1:Request><param0 xsi:type="xsd:string">null</param0><param1 xsi:type="xsd:string">null</param1></Request>


from Associative array key becomes param in XML when passed to SoapClient

No comments:

Post a Comment