christoph-schaeffer / dhl-business-shipping

An unofficial library for the DHL business shipping soap API (Version 3.3) and the dhl shipment tracking rest API written in PHP.
MIT License
29 stars 8 forks source link

SECURITY_VIOLATION in production mode #11

Closed Magellanth closed 2 years ago

Magellanth commented 2 years ago

Hi,

i tested this library over the last weeks in sandbox mode and everything worked fine, now i tried to switch to production mode and i get an Exception with "SECURITY_VIOLATION" on any soap call.

The login, appID and apiToken i am using is in productive use with another library (petschko) which is using DHL GKV API 2.2 and there it works fine. The Login also works manually on the GKV website and the password is valid for another month. The application is approved and in production for years.

I reduced my test script to:

use ChristophSchaeffer\Dhl\BusinessShipping\Client;

$client = new Client(
    'myAppID',
    'myAppToken',
    'myGkvUsername',
    'myGkvPassword',
    false
);

$request = new \ChristophSchaeffer\Dhl\BusinessShipping\Request\getVersion();
$response = $client->getVersion($request);

The Exception is:

_Uncaught SoapFault exception: [soap:Client] SECURITY_VIOLATION in /.../vendor/christoph-schaeffer/dhl-business-shipping/src/Soap.php:54

Stack trace:

0 /.../vendor/christoph-schaeffer/dhl-business-shipping/src/Soap.php(54): SoapClient->_call('getVersion', Array)

Am i missing anything here? Is it possible to see the raw request xml when an exception occurs before i get a response?

christoph-schaeffer commented 2 years ago

Hello @Magellanth,

first thanks for using the library :-)

You can access the raw request xml on the response object. I'm using the php soap extension and couldn't figure out how to get the xml before sending something, thats why it's in the response object. However this should work in your case either way.

echo $response->rawRequest; // this is the raw xml which has been sent to DHL as a string
echo $response->rawResponse; // this is the raw response which the DHL API returned as an object.

However i think i know what is causing your issue, because i had the same issue as well.

TLDR: You need to contact the DHL "Entwicklerportal" support and tell them to enable your developer account for version 3.1

Long Version: DHL has an authentication process in their api which locks/unlocks specific versions. I guess this is the case because they plan to deprecate version 2.0 and don't want new users to be able to use that version. For some weird reason this authentication isn't used for the sandbox mode.

The funny part is this happend to me with a brend new account when 3.0 was out... I think it's the same for you.

I contacted their support on the "Entwicklerportal" unfortunaly you can only contact them by opening a ticket. However i highly recommend that you just tell them, that you think your developer account is not unlocked for version 3.1 and leave them your phone number and your usual business hours when you can be called.

They will most likely walk you through setting up soap ui with their test suite to make sure that it is not your implementation that is not working. Which you could actually do by yourself now, too if you want to make sure that i'm correct :-)

Go to https://entwickler.dhl.de/group/ep/testsuite8 their you can find instructions how to get it to work.

For me the issue persisted even in soapUI which made it clear that it was not the implementation but rather an authentication issue.

Magellanth commented 2 years ago

Thank you, i am going to test it with SoapUI and then contact the Support.

Magellanth commented 2 years ago

Support already responded, they activated 3.x Support - now everything works as expected.

Nice work DHL not communicating this limitation...

christoph-schaeffer commented 2 years ago

glad to hear that :-)

Yes, i would prefer to get an error like "your account is not activated for version 3.X" or something similar...

I'm closing the issue since your issue seems to be resolved. 👍