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

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

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

        PHP SoapClient:SoapFault 异常无法连接到主机

        时间:2023-05-22
          <legend id='QKwUd'><style id='QKwUd'><dir id='QKwUd'><q id='QKwUd'></q></dir></style></legend>

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

          <i id='QKwUd'><tr id='QKwUd'><dt id='QKwUd'><q id='QKwUd'><span id='QKwUd'><b id='QKwUd'><form id='QKwUd'><ins id='QKwUd'></ins><ul id='QKwUd'></ul><sub id='QKwUd'></sub></form><legend id='QKwUd'></legend><bdo id='QKwUd'><pre id='QKwUd'><center id='QKwUd'></center></pre></bdo></b><th id='QKwUd'></th></span></q></dt></tr></i><div id='QKwUd'><tfoot id='QKwUd'></tfoot><dl id='QKwUd'><fieldset id='QKwUd'></fieldset></dl></div>
                <tbody id='QKwUd'></tbody>
                  <bdo id='QKwUd'></bdo><ul id='QKwUd'></ul>
                  <tfoot id='QKwUd'></tfoot>
                  本文介绍了PHP SoapClient:SoapFault 异常无法连接到主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  使用此代码我发出肥皂请求

                  using this code I make soap requests

                  $client = new SoapClient('http://example.com/soap/wsdl');
                  
                  try {
                      $result = $client->myMethod();
                  } catch (Exception $e) {
                      echo $e->getMessage();
                  }
                  

                  有时(十分之一),会引发异常:

                  Sometimes (once out of ten), an exception is raised:

                  SoapFault 异常:[HTTP] 无法连接到主机

                  SoapFault exception: [HTTP] Could not connect to host

                  我的尝试

                  1) 我寻找解决方案,我读到这个问题可能是由 wsdl 缓存引起的,我在 php.ini 中禁用了它:

                  1) I looked for solutions, and I read that this problem can be caused by wsdl cache, I disabled it in php.ini:

                  soap.wsdl_cache_enabled = 0
                  soap.wsdl_cache_ttl = 0
                  

                  引发更少的异常

                  2) 我试图将 windows/system32/drivers/etc/hosts 中 dns 的分辨率添加到 windows 主机(它们在 windows 上):

                  2) I tried to add to the host of windows (they are on windows) the resolution of the dns in windows/system32/drivers/etc/hosts:

                  160.XX.XXX.XX example.com
                  

                  引发更少的异常

                  3) 我也尝试禁用Windows 防火墙",

                  3) I also tried to disable "Windows Firewall",

                  引发更少的异常

                  4) 我也尝试增加 php.ini 中的 default_socket_timeout

                  4) I also tried to increase the default_socket_timeout in php.ini

                  default_socket_timeout = 90
                  

                  什么都没有改变

                  问题

                  服务器soap似乎没有问题.从其他站点也可以正常使用.还有什么我可以做的吗?

                  The server soap does not seem to have problems.It is used without problems also from other sites. Is there anything else I can do?

                  我的设置

                  PHP 5.6

                  阿帕奇 2.4

                  Windows Server 2012

                  Windows Server 2012

                  更新

                  经过多次测试,我认为问题出在网络上,soap server后面有一个反向代理,问题出现在代理上.

                  After many tests, I think that the problem is in the network, soap server is behind a reverse proxy, the problem appears in the proxy.

                  推荐答案

                  您需要进一步改进调试工作:

                  You need to improve your debugging efforts even further:

                  ad 1) WSDL 变化很大吗?如果没有,打开 WSDL 缓存.您无需连接到服务器即可获取 WSDL 文件.

                  ad 1) Does the WSDL change a lot? If not, turn on WSDL caching. You don't need to connect to the server to fetch the WSDL file.

                  你提到的输出真的是在 echo $e->getMessage(); 中创建的吗?您可以在 catch() 块中添加一些调试代码,例如:

                  Is the output you mentioned really created in echo $e->getMessage();? You could add some debugging code inside the catch() block, for example:

                  • 检查您是否可以通过其他方式连接到服务器(例如 file_get_contents($soap_url))
                  • 如果没有,请检查您遇到的错误类型
                    • 打印时间并检查 SOAP 服务器上的错误日志
                    • 一个 403 Forbidden 或类似服务器上的问题的错误点
                    • 无法连接错误指向网络问题(并非唯一,但这种情况的可能性更高)
                    • check if you can connect to the server in another way (for example file_get_contents($soap_url))
                    • if not, check what kind of error you are getting
                      • print the time and check the error logs on the SOAP server
                      • a 403 Forbidden or similar error points on a problem on the server
                      • a Could not connect error points to a network problem (not exclusively but chances are higher for that)

                      总而言之,有时错误"很难调试,因此您要么应该尝试使其可重现(这将指向问题),要么您需要记录和输出尽可能多的数据,以便您可以查看问题发生时的位置.

                      All in all, "sometimes errors" are hard to debug, so either you should try to make it reproducible (which will point at the problem), or you need to record and output as much data as possible so that you can see where the problem was at the time when it occurred.

                      这篇关于PHP SoapClient:SoapFault 异常无法连接到主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP中P_SHA1算法的实现 下一篇:不是有效的 AllXsd 值

                  相关文章

                  最新文章

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

                      <tfoot id='KaW9y'></tfoot><legend id='KaW9y'><style id='KaW9y'><dir id='KaW9y'><q id='KaW9y'></q></dir></style></legend>
                    1. <small id='KaW9y'></small><noframes id='KaW9y'>

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