【问题标题】:How do i view the "raw xml" output from nusoap?如何查看 nusoap 的“原始 xml”输出?
【发布时间】:2011-04-06 02:17:07
【问题描述】:

我有一个用于传递 SOAP 命令的通用函数。我需要查看正在 发送 到服务器的 RAW XML 数据以诊断错误。我该怎么做?

【问题讨论】:

    标签: php xml soap nusoap


    【解决方案1】:

    没关系,这似乎非常接近点!

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

    【讨论】:

      【解决方案2】:

      虽然这是一篇旧帖子,但我想用我自己的 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');
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-10-31
        • 1970-01-01
        • 1970-01-01
        • 2014-05-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多