core icon indicating copy to clipboard operation
core copied to clipboard

Soap Trace Options

Open nickhagen opened this issue 4 years ago • 1 comments

So it seems the way that the SOAP driver functions is to call set_defaults() during the execute() function, this seems to be problematic for the debugging functions found here: https://fuelphp.com/docs/classes/request/soap.html

  • get_request_xml
  • get_request_headers
  • get_response_xml
  • get_response_headers

These function all require the trace option to be enabled, however, the data from these functions only gets populated AFTER the call executes! So if you try to print get_request_xml before you execute it is always null, if you call this function after execute, then the trace option gets reset on soap.php line 148 with $this->set_defaults();

Commenting out line 148 "fixes" the trace function and allows these functions to seemingly work properly, however, I am not sure why you would want to call set_defaults after a request is executed enough. Perhaps you are calling execute() multiple times in a row ... but i would think you would still change the function and the parameter or headers that need to change before making the next couple calls?

Test case

$soap = Request::forge('https://api.cvent.com/soap/V200611.asmx?WSDL', 'soap');
$soap->set_function('Login');
$soap->set_option('trace', true);
$soap->set_option('connection_timeout', 45);
$soap->set_params([[
     'AccountNumber' => '123456',
     'UserName' => 'TestAccount',
     'Password' => 'thisCantBeCorrect',
]]);

$soap->execute();

nickhagen avatar Nov 06 '20 15:11 nickhagen

It is indeed to use the same soap object for multiple requests, instead of forging a new one for each request.

If you pass "trace" as one of the options in the forge() request, it is considered a default option for the request, while set_option() is a runtime option, and only active for that request (execute call).

So you need to use

$soap = Request::forge('https://api.cvent.com/soap/V200611.asmx?WSDL', array('driver'=>'soap', 'trace' => true));

WanWizard avatar Nov 06 '20 17:11 WanWizard