How do I see the actual XML generated by PHP SOAP Client Class?

后端 未结 7 1647
醉酒成梦
醉酒成梦 2020-12-05 01:42

Consider this example SOAP Client script:

$SOAP = new SoapClient($WDSL); // Create a SOAP Client from a WSDL

// Build an array of data to send in the reques         


        
7条回答
  •  失恋的感觉
    2020-12-05 02:10

    The problem with Quinn Comendant's answer, that $request from __doRequest() will then be processed by __call() and the user will see an array of parameters instead of real xml request. To prevent this, such workaround can be used:

    class DummySoapClient extends SoapClient {
        function __construct($wsdl, $options) {
            parent::__construct($wsdl, $options);
        }
    
        function __doRequest($request, $location, $action, $version, $one_way = 0) {
            throw new Exception($request);
        }
    
        function __call($function_name, $arguments)
        {
            try {
                parent::__call($function_name, $arguments);
            } catch (Exception $e) {
                return $e->getMessage();
            }
        }
    }
    

    Option trace is not necessary here, because we do not call __getLastRequest() or other relevant functions.

提交回复
热议问题