<tfoot id='yX4yN'></tfoot>

    <small id='yX4yN'></small><noframes id='yX4yN'>

      <i id='yX4yN'><tr id='yX4yN'><dt id='yX4yN'><q id='yX4yN'><span id='yX4yN'><b id='yX4yN'><form id='yX4yN'><ins id='yX4yN'></ins><ul id='yX4yN'></ul><sub id='yX4yN'></sub></form><legend id='yX4yN'></legend><bdo id='yX4yN'><pre id='yX4yN'><center id='yX4yN'></center></pre></bdo></b><th id='yX4yN'></th></span></q></dt></tr></i><div id='yX4yN'><tfoot id='yX4yN'></tfoot><dl id='yX4yN'><fieldset id='yX4yN'></fieldset></dl></div>
        <bdo id='yX4yN'></bdo><ul id='yX4yN'></ul>
      <legend id='yX4yN'><style id='yX4yN'><dir id='yX4yN'><q id='yX4yN'></q></dir></style></legend>
      1. 在发送请求之前/不发送请求之前检查由 PHP Soap

        时间:2023-05-22
        • <bdo id='oe39B'></bdo><ul id='oe39B'></ul>
              <tbody id='oe39B'></tbody>

                <small id='oe39B'></small><noframes id='oe39B'>

                <tfoot id='oe39B'></tfoot><legend id='oe39B'><style id='oe39B'><dir id='oe39B'><q id='oe39B'></q></dir></style></legend>

                  <i id='oe39B'><tr id='oe39B'><dt id='oe39B'><q id='oe39B'><span id='oe39B'><b id='oe39B'><form id='oe39B'><ins id='oe39B'></ins><ul id='oe39B'></ul><sub id='oe39B'></sub></form><legend id='oe39B'></legend><bdo id='oe39B'><pre id='oe39B'><center id='oe39B'></center></pre></bdo></b><th id='oe39B'></th></span></q></dt></tr></i><div id='oe39B'><tfoot id='oe39B'></tfoot><dl id='oe39B'><fieldset id='oe39B'></fieldset></dl></div>
                1. 本文介绍了在发送请求之前/不发送请求之前检查由 PHP SoapClient 调用创建的 XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  问题:有没有办法在您实际发送请求之前查看使用 PHP SoapClient 函数调用创建的 XML?

                  The question: Is there a way to view the XML that would be created with a PHP SoapClient function call BEFORE you actually send the request?

                  背景:

                  我是 WSDL 通信的新手,我有一个客户希望我用 PHP 进行开发,这是一种与用 ASP.NET 编写的 WSDL 服务进行通信的方式.我已经走得很远了,但是在传递复杂类型时遇到了问题.到目前为止,我已经尝试了几种不同的方法.

                  I am new to WSDL communication, and I have a client who wants me to develop in PHP, a way to communicate with a WSDL service written in ASP.NET. I have gotten pretty far, but am running into an issue when it comes to passing a complex type. I have tried a couple of different things so far.

                  1) 设置单个数组如$params->Person->name $params->Person->address

                  1) Setting up a single array such as $params->Person->name $params->Person->address

                  2) 设置单个数组 $Person = array('name'=>"joe",'address' = "123");

                  然后作为参数"Person" => $Person;和其他一些人.但是每次我收到错误

                  then passing into the call as a param "Person" => $Person; and a few others. But every time I get the error

                  SoapException:服务器无法处理请求 ---> System.Exception:人是必需的.在服务名称.

                  SoapException: Server was unable to process request ---> System.Exception: Person is Required. at service name.

                  为了进一步排除故障,我想查看正在发送的 XML 文档,以查看它是否按照我期望的方式创建了复杂类型.我正在使用 $client = new SoapClient('wsdldoc.asmx?WSDL'); 创建服务,使用 $client->CreateUser($params); 和然后尝试使用 $client->__getLastRequest(); 函数查看它,但它永远不会进入 __getLastRequest,因为它在调用 CreateUser($params) 时遇到了致命错误.

                  In order to further the troubleshooting, I would like to see the XML document that is being sent to see if it is creating a complex type in the way I am expecting it to. I am creating the service using $client = new SoapClient('wsdldoc.asmx?WSDL'); calling it with $client->CreateUser($params); and then trying to see it using the function $client->__getLastRequest(); but it never makes it to the __getLastRequest because it hits a fatal error when calling CreateUser($params).

                  再次提问:有什么方法可以查看由 CreateUser($params) 调用创建的 XML 而不实际发送它并导致致命错误

                  The question again: Is there any way to view the XML created by the CreateUser($params) call WITHOUT actually sending it and causing a fatal error

                  推荐答案

                  前言:为了使用__getLastRequest() 方法成功,您必须在客户端构建时将 'trace' 选项设置为 true:

                  Upfront remark: In order to use the __getLastRequest() method successfully, you have to set the 'trace' option to true on client construction:

                  $client = new SoapClient('wsdldoc.asmx?WSDL', array('trace' => TRUE));
                  

                  这样,您的请求仍将被发送(因此仍然失败),但您可以通过调用$client->之后检查发送的xml;__getLastRequest().

                  This way, your request will still be sent (and therefore still fail), but you can inspect the sent xml afterwards by calling $client->__getLastRequest().

                  主要答案:

                  要在发送请求之前/不访问生成的 XML,您需要子类化 SoapClient 以覆盖 __doRequest() 方法:

                  To get access to the generated XML before/without sending the request, you'd need to subclass the SoapClient in order to override the __doRequest() method:

                  class SoapClientDebug extends SoapClient
                  {
                    public function __doRequest($request, $location, $action, $version, $one_way = 0) {
                        // Add code to inspect/dissect/debug/adjust the XML given in $request here
                  
                        // Uncomment the following line, if you actually want to do the request
                        // return parent::__doRequest($request, $location, $action, $version, $one_way);
                    }
                  }
                  

                  然后,您将在调试问题时使用此扩展类而不是原始 SoapClient.

                  You'd then use this extended class instead of the original SoapClient while debugging your problem.

                  这篇关于在发送请求之前/不发送请求之前检查由 PHP SoapClient 调用创建的 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:SoapFault 异常:无法连接到主机 下一篇:如何查看 PHP SOAP 客户端类生成的实际 XML?

                  相关文章

                  最新文章

                    <bdo id='MdfA8'></bdo><ul id='MdfA8'></ul>

                      <i id='MdfA8'><tr id='MdfA8'><dt id='MdfA8'><q id='MdfA8'><span id='MdfA8'><b id='MdfA8'><form id='MdfA8'><ins id='MdfA8'></ins><ul id='MdfA8'></ul><sub id='MdfA8'></sub></form><legend id='MdfA8'></legend><bdo id='MdfA8'><pre id='MdfA8'><center id='MdfA8'></center></pre></bdo></b><th id='MdfA8'></th></span></q></dt></tr></i><div id='MdfA8'><tfoot id='MdfA8'></tfoot><dl id='MdfA8'><fieldset id='MdfA8'></fieldset></dl></div>

                    1. <tfoot id='MdfA8'></tfoot>
                    2. <small id='MdfA8'></small><noframes id='MdfA8'>

                      <legend id='MdfA8'><style id='MdfA8'><dir id='MdfA8'><q id='MdfA8'></q></dir></style></legend>