I have an example in XML:
<?xml version="1.0" encoding="windows-1250"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ImportPackagesExt xmlns="PPLIEGate">
<FirCode>ppltest</FirCode>
<Packages>
<Items>
<anyType xsi:type="Package">
<PackageID>40080145103</PackageID>
<ZipCode>16300</ZipCode>
<Country>CZ</Country>
<ErrorCode>0</ErrorCode>
<ErrorMessage></ErrorMessage>
</anyType>
<anyType xsi:type="Package">
<PackageID>40010529207</PackageID>
<ZipCode>15500</ZipCode>
<Country>CZ</Country>
<ErrorCode>0</ErrorCode>
<ErrorMessage></ErrorMessage>
</anyType>
</Items>
</Packages>
</ImportPackagesExt>
</soap:Body>
</soap:Envelope>
But this my PHP script returns an error.
$packs = [
[
'PackageID' => '40080145103',
'ZipCode' => '16300',
'Country' => 'CZ',
'ErrorCode' => 0,
'ErrorMessage' => '',
],
[
'PackageID' => '40010529207',
'ZipCode' => '15500',
'Country' => 'CZ',
'ErrorCode' => 0,
'ErrorMessage' => '',
],
];
$items = [];
foreach ($packs as $pack) {
$items[] = new SoapVar($pack, SOAP_ENC_ARRAY, XSD_ANYTYPE, null, 'Package');
}
$packages = [
'FirCode' => $firCode,
'Packages' => [
'Items' => $items,
'ErrorCode' => 0,
],
'DepID' => '00',
];
$response = $soap->ImportPackagesExt($packages);
Error says: Server was unable to process request. ---> Unable to cast object of type 'System.Xml.XmlNode[]' to type 'Package'.
I still can not figure out how to define a structure for the "Package".