Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is getLastRequest not returning anything?

Tags:

php

soap

xml

I am trying to get the XML request:

$cgProxy = new SoapClient($WSDL_URL,array('trace' => 1));

try {
        $result = $cgProxy->OrderCreate($cgOrder);

} catch (SoapFault $exc) {
        var_dump($exc);
        echo "Request:\n" . $cgProxy->__getLastRequest(), "\n";
        echo "Response:\n" . $cgProxy->__getLastResponse() . "\n";
}

With this I get the soap server error from the $exc dump. But the getLastRequest does not seem to be returning anything. Any thoughts?

I have also tried with htmlspecialchars() and htmlentities() without success . . .

like image 232
evan Avatar asked Mar 16 '12 18:03

evan


3 Answers

I know this is late, but...

Its possible you are never actually making the request. If PHP fails to create the SOAP call, you won't ever get to the point where you are sending the XML request. Check your error log for PHP SOAP errors.

like image 72
John Vargo Avatar answered Oct 16 '22 22:10

John Vargo


getLastRequest():

This method works only if the SoapClient object was created with the trace option set to TRUE.

$client = new SoapClient("http://myservice/?WSDL",array("trace"=>1));

in this case works for me.

like image 29
Rıdvan Nuri Göçmen Avatar answered Nov 16 '22 09:11

Rıdvan Nuri Göçmen


Maybe because the XML in your browser doesn't print as string. If so, try something like this:

echo "REQUEST:\n" . htmlentities($client->__getLastRequest()) . "\n";
like image 10
user3506467 Avatar answered Nov 16 '22 09:11

user3506467