I have the SOAP endpoint and I would like to use PHP's \SoapClient class to send the request. The problem is that even if the "senderAddress" attribute has eg. "name", "nameDetail", "type" attributes (some of them are required by the docs), the generated XML request does not contain them. The only attribute it accepts/generates is the "id" attribute.
The same problem is also in another parts of the shipment object - f.ex. The Pickup part allows me to set just the "date" attribute, all of the others are skipped/ignored.
I've prepared some dummy code below, without data objects, just a simple array:
<?php
$soapClient = new \SoapClient("https://capi.dpdportal.sk/apix/shipment/?wsdl", [
'trace' => 1
]);
$headers = array();
$dpdSecurity = new \stdClass();
$token = new \stdClass();
$token->ClientKey = "topsecretkey";
$token->Email = "topsecretmail";
$dpdSecurity->SecurityToken = $token;
$headers["auth"] = new \SoapHeader('http://www.dpdportal.sk/XMLSchema/DPDSecurity/v2', 'DPDSecurity', $dpdSecurity);
$soapClient->__setSoapHeaders($headers);
$shipment = [
"reference" => "123",
"delisId" => "123",
"addressSender" => [
"type" => "b2c", // this attribute is missing in the Request
"id" => 41656415651,
"nameDetail" => "test", // this attribute is missing in the Request
],
"addressRecipient" => "123",
"product" => 9,
"parcels" => [],
"pickup" => null,
];
$params = [
'shipment' => $shipment,
];
try {
$response = $soapClient->CreateV1($params);
echo '==' . PHP_EOL;
var_dump($response);
} catch (\Exception $e) {
echo $e->getMessage();
}
Generated Request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.dpdportal.sk/XMLSchema/SHIPMENT/v1" xmlns:ns2="http://www.dpdportal.sk/XMLSchema/DPDSecurity/v2">
<SOAP-ENV:Header>
<ns2:DPDSecurity>
<ns2:SecurityToken>
<ns2:ClientKey>topsecretkey</ns2:ClientKey>
<ns2:Email>topsecretmail</ns2:Email>
</ns2:SecurityToken>
</ns2:DPDSecurity>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:CreateRequest>
<ns1:shipment>
<ns1:reference>123</ns1:reference>
<ns1:delisId>123</ns1:delisId>
<ns1:product>9</ns1:product>
<ns1:pickup />
<ns1:addressSender>
<ns1:id>41656415651</ns1:id>
</ns1:addressSender>
<ns1:addressRecipient />
<ns1:parcels />
</ns1:shipment>
</ns1:CreateRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>