php 我如何查看 nusoap 的“原始 xml”输出?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3606239/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do i view the "raw xml" output from nusoap?
提问by tzmatt7447
I have a generic function that I use to pass SOAP commands. I need to view the RAW XML data that is being sentto the server for diagnosing an error. How do i do that?
我有一个通用函数,用于传递 SOAP 命令。我需要查看发送到服务器以诊断错误的 RAW XML 数据。我怎么做?
回答by tzmatt7447
Never mind, this seems to be pretty close to the dot!
没关系,这似乎非常接近点!
http://www.scottnichol.com/nusoapintro.htm
http://www.scottnichol.com/nusoapintro.htm
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
回答by Chris
While this is an old post i wanted to chip in with my own version of tzmatt answer.
虽然这是一篇旧帖子,但我想用我自己版本的 tzmatt 答案来补充。
class soapBug {
/*
* @var obj $debug client object
* @var string $what Just a name for the header so you know
* what you are looking at.
*/
public function bug($debug, $what) {
/* ive stayed with the original here, but you could look at
* http://www.php.net/manual/en/tidy.repairstring.php to
* output in clean xml.
*
* I just grab the line i need and paste
* it into my IDE and let it format for me, works just as well
* and no coding to fiddle with for something that wont be
* permanent on my project.
*/
echo '<h2>' . $what . '</h2>';
echo '<pre>' . htmlspecialchars($debug, ENT_QUOTES) . '</pre>';
}
}
class someClass {
private $de;
// private to this class to prevent accidental call
// outside the class.
public function __construct() {
$this->de = new soapBug;
}
public function thatNeedsDebugging() {
/*
* Simple enough to debug your client now no need to copy
* the html block all over you can debug with just one line
* of call all of them
*/
$this->de->bug($client->request, 'Request'); // I grab this output string
$this->de->bug($client->response, 'Response');
$this->de->bug($client->debug_str, 'Debug');
}
}

