問題描述
考慮這個示例 SOAP 客戶端腳本:
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 request.
$Data = array('Something'=>'Some String','SomeNumber'=>22);
$Response = $SOAP->DoRemoteFunction($Data); // Send the request.
在最后一行,PHP 從您指定的數組中獲取參數,并使用 WSDL 構建要發送的 XML 請求,然后將其發送.
On the last line, PHP takes the arguments from the array you specified, and, using the WSDL, builds the XML request to send, then sends it.
如何讓 PHP 向我展示它構建的實際 XML?
How can I get PHP to show me the actual XML it's built?
我正在對應用程序進行故障排除,需要查看請求的實際 XML.
I'm troubleshooting an application and need to see the actual XML of the request.
推薦答案
使用 getLastRequest
.它返回在最后一個 SOAP 請求中發送的 XML.
Use getLastRequest
. It returns the XML sent in the last SOAP request.
echo "REQUEST:
" . $SOAP->__getLastRequest() . "
";
請記住,此方法僅在創建 SoapClient 對象且 trace
選項設置為 TRUE
時才有效.因此,在創建對象時,使用以下代碼:
And remember, this method works only if the SoapClient object was created with the trace
option set to TRUE
. Therefore, when creating the object, use this code:
$SOAP = new SoapClient($WDSL, array('trace' => 1));
這篇關于如何查看 PHP SOAP 客戶端類生成的實際 XML?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!