简体   繁体   中英

why is getLastRequest not returning anything?

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 . . .

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.

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";

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM