Hier ein schnelles Beispiel, wie die per PHP SoapClient() und DPD-WSDL-Schnittstelle ein Versand-Etikett als PDF generiert werden kann.
Für Suchmaschinen: PHP SOAP-Header für Authentifizierung, authenticate SOAP-Header, DPD-Api Versandetikett generieren, Generate DPD Label, DPD parse SOAP response, Fatal error: Uncaught SoapFault exception: [soap:Server] Fault occurred while processing. in getLabel.php:107 Stack trace: #0 getLabel.php(107): SoapClient->__call(’storeOrders‘, Array) #1 getLabel.php(107): SoapClient->storeOrders(Array).
getAuth(array(
'delisId' => 'your-Id',
'password' => 'your-Password',
'messageLanguage' => 'de_DE'
));
// ...und das Token merken
$auth = $res->return;
// Jetzt das Label generieren:
$c = new SoapClient('https://public-ws-stage.dpd.com/services/ShipmentService/V3_1?wsdl');
$token = array(
'delisId' => $auth->delisId,
'authToken' => $auth->authToken,
'messageLanguage' => 'de_DE'
);
// Set the header with the authentication token
$header = new SOAPHeader('http://dpd.com/common/service/types/Authentication/2.0', 'authentication', $token);
$c->__setSoapHeaders($header);
try {
$res = $c->storeOrders( array
(
"printOptions" => array(
"paperFormat" => "A4",
"printerLanguage" => "PDF"
),
"order" => array(
"generalShipmentData" => array(
"sendingDepot" => $auth->depot,
"product" => "CL",
"mpsCompleteDelivery" => false,
"sender" => array(
"name1" => "Sender Name",
"street" => "Sender Street 2",
"country" => "DE",
"zipCode" => "65189",
"city" => "Wiesbaden",
"customerNumber" => "123456789"
),
"recipient" => array(
"name1" => "John Malone",
"street" => "Johns Street 34",
"country" => "DE",
"zipCode" => "65201",
"city" => "Wiesbaden"
)
),
"parcels" => array(
"parcelLabelNumber" => "09123829120"
),
"productAndServiceData" => array(
"orderType" => "consignment"
)
)
)
);
} catch (SoapFault $exception) {
echo $exception->getMessage();
die();
}
// Et voilà!
header('Content-type: application/pdf');
echo $res->orderResult->parcellabelsPDF;
?>
Hallo,
aber wie komme ich zwei Kunden ausgedruckt, quasi 2x ?
0998
CL
DPD Deutschland GmbH
Wailandtstr. 1
DE
63741
Aschaffenburg
DPD Deutschland GmbH
Stockstädter Straße
10
DE
63762
Großostheim
400
consignment
1
consignee@email.com
0998
CL
DPD Deutschland GmbH
Wailandtstr. 1
DE
63741
Aschaffenburg
DPD Deutschland GmbH
Stockstädter Straße
10
DE
63762
Großostheim
400
consignment
1
consignee@email.com
Vielen Dank