dreamfactorysoftware / df-soap

DreamFactory service for connecting to SOAP services.
Other
1 stars 2 forks source link

SoapHeader #1

Closed repat closed 8 years ago

repat commented 8 years ago

Hi,

Background: I would like to use the SOAP API of Plentymarkets with DreamFactory.

Problem: At the moment I'm getting the attached error message for GetServerTime with an empty body.

Solution: I'm pretty sure that the SoapHeader would be required, but I can't find an option for it. I can however set Options in the settings, but as far as I understood it's this options array:

public SoapClient::SoapClient ( mixed $wsdl [, array $options ] )

However, the token I need for authorization needs to go in the header, see documentation (for my specific use case) here: https://www.plentymarkets.co.uk/manual/data-exchange/soap-api/authentication/

I think others might have that problem too, e.g. this forum post from Feb '15.

Error message:

{
  "error": {
    "context": null,
    "message": "Unauthorized Request - Token required",
    "code": 500,
    "trace": [
      "0 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-soap/src/Services/Soap.php(253): SoapClient->__call('GetServerTime', Array)",
      "1 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-soap/src/Services/Soap.php(253): SoapClient->GetServerTime(Array)",
      "2 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-soap/src/Services/Soap.php(292): DreamFactory\\Core\\Soap\\Services\\Soap->callFunction('GetServerTime', Array)",
      "3 [internal function]: DreamFactory\\Core\\Soap\\Services\\Soap->handlePost()",
      "4 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Components/RestHandler.php(267): call_user_func(Array)",
      "5 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Components/RestHandler.php(173): DreamFactory\\Core\\Components\\RestHandler->processRequest()",
      "6 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Services/BaseRestService.php(65): DreamFactory\\Core\\Components\\RestHandler->handleRequest(Object(DreamFactory\\Core\\Utility\\ServiceRequest), 'GetServerTime')",
      "7 /opt/bitnami/apps/dreamfactory/htdocs/vendor/dreamfactory/df-core/src/Utility/ServiceHandler.php(70): DreamFactory\\Core\\Services\\BaseRestService->handleRequest(Object(DreamFactory\\Core\\Utility\\ServiceRequest), 'GetServerTime')",
      "8 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(16822): DreamFactory\\Core\\Utility\\ServiceHandler::processRequest('v2', 'pm', 'GetServerTime')",
      "9 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(16798): DreamFactory\\Http\\Controllers\\RestController->handleService('v2', 'pm', 'GetServerTime')",
      "10 [internal function]: DreamFactory\\Http\\Controllers\\RestController->handlePOST('v2', 'pm', 'GetServerTime')",
      "11 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(8982): call_user_func_array(Array, Array)",
      "12 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9044): Illuminate\\Routing\\Controller->callAction('handlePOST', Array)",
      "13 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9024): Illuminate\\Routing\\ControllerDispatcher->call(Object(DreamFactory\\Http\\Controllers\\RestController), Object(Illuminate\\Routing\\Route), 'handlePOST')",
      "14 [internal function]: Illuminate\\Routing\\ControllerDispatcher->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "15 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "16 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(16980): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "17 [internal function]: DreamFactory\\Http\\Middleware\\AccessCheck->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "18 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "19 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "20 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "21 [internal function]: Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "22 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9501): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "23 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9025): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
      "24 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9012): Illuminate\\Routing\\ControllerDispatcher->callWithinStack(Object(DreamFactory\\Http\\Controllers\\RestController), Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request), 'handlePOST')",
      "25 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(8099): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request), 'DreamFactory\\\\Ht...', 'handlePOST')",
      "26 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(8086): Illuminate\\Routing\\Route->runController(Object(Illuminate\\Http\\Request))",
      "27 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(7800): Illuminate\\Routing\\Route->run(Object(Illuminate\\Http\\Request))",
      "28 [internal function]: Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "29 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "30 [internal function]: Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "31 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9501): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "32 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(7801): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
      "33 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(7792): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))",
      "34 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(7782): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))",
      "35 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(2393): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))",
      "36 [internal function]: Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))",
      "37 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "38 /opt/bitnami/apps/dreamfactory/htdocs/app/Http/Middleware/AuthCheck.php(170): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "39 [internal function]: DreamFactory\\Http\\Middleware\\AuthCheck->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "40 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "41 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "42 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "43 /opt/bitnami/apps/dreamfactory/htdocs/vendor/barryvdh/laravel-cors/src/HandleCors.php(34): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "44 [internal function]: Barryvdh\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "45 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "46 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "47 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "48 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(17072): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "49 [internal function]: DreamFactory\\Http\\Middleware\\FirstUserCheck->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "50 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "51 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "52 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "53 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(12935): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "54 [internal function]: Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "55 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "56 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "57 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "58 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(11495): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "59 [internal function]: Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "60 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "61 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "62 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "63 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(12674): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "64 [internal function]: Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "65 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "66 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "67 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "68 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(12611): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "69 [internal function]: Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "70 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "71 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "72 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "73 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(3226): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "74 [internal function]: Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))",
      "75 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9511): call_user_func_array(Array, Array)",
      "76 [internal function]: Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))",
      "77 /opt/bitnami/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "78 [internal function]: Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))",
      "79 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9501): call_user_func(Object(Closure), Object(Illuminate\\Http\\Request))",
      "80 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(2340): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))",
      "81 /opt/bitnami/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(2324): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))",
      "82 /opt/bitnami/apps/dreamfactory/htdocs/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))",
      "83 {main}"
    ]
  }
}```
repat commented 8 years ago

This is how the SDK does it, so something like this configurable like the config array would be good.

$aHeader = array('UserID' => 42, 'Token' => "abcdef123456");
$auth_vals = new SoapVar($aHeader, SOAP_ENC_OBJECT);
$ns = "Authentification";
$oSoapHeader = new SoapHeader($ns, 'verifyingToken', $auth_vals, false);
$this->client->__setSoapHeaders($oSoapHeader);

I'm still getting a 500 error for this one, which might not be Dreamfactory's fault though.

df-arif commented 8 years ago

We have added soap header option on the soap service config tab and it's getting ready to be shipped in the next release of DreamFactory.

screen shot 2016-05-26 at 9 47 37 am