SoapFault exception: Could not connect to host

后端 未结 27 1515
-上瘾入骨i
-上瘾入骨i 2020-12-01 07:47

Sometimes fail to call the web service.

This problem happens all the time.

What could be the problem?

Error:
    SoapFault exception: [HTTP]          


        
相关标签:
27条回答
  • 2020-12-01 08:29

    For me, this was a problem in the httpd service (Fedora 24). A simple restart did the trick:

    sudo service httpd restart
    
    0 讨论(0)
  • 2020-12-01 08:32

    A misconfigured service leaves the default namespace with tempuri.org

    This means the connection to the wsdl will work, but the function call will fail.

    Stacktrace:

    SoapClient->__doRequest('http://example.com...', 'http://tempuri.org....', 2, 0)

    To remediate this, you must explicitly set the location using __setLocation()

    $this->soapClient = new \SoapClient(WS_URL);
    $this->soapClient->__setLocation(WS_URL);
    
    0 讨论(0)
  • 2020-12-01 08:32

    That most likely refers to a connection issue. It could be either that your internet connection was down, or the web service you are trying to use was down. I suggest using this service to see if the web service is online or not: http://downforeveryoneorjustme.com/

    0 讨论(0)
  • 2020-12-01 08:33

    I am adding my comment for completeness, as the solutions listed here did not help me. On PHP 5.6, SoapClient makes the first call to the specified WSDL URL in SoapClient::SoapClient and after connecting to it and receiving the result, it tries to connect to the WSDL specified in the result in:

    <soap:address location="http://"/>
    

    And the call fails with error Could not connect to host if the WSDL is different than the one you specified in SoapClient::SoapClient and is unreachable (my case was SoapUI using http://host.local/).

    The behaviour in PHP 5.4 is different and it always uses the WSDL in SoapClient::SoapClient.

    0 讨论(0)
  • 2020-12-01 08:34

    there is a soap config section in your php.ini file, which control the wsdl access cache, may be shown as:

    [soap] 
    ; Enables or disables WSDL caching feature. 
    soap.wsdl_cache_enabled=1 ; 
    Sets the directory name where SOAP extension will put cache files. 
    soap.wsdl_cache_dir="/tmp" 
    ; (time to live) Sets the number of second while cached file will be used ; instead of original one.  
    soap.wsdl_cache_ttl=86400
    

    if wsdl file cache is enabled, it may cause this problem when changing wsdl URI in php code. in this example, you can just delete file start with wsdl- under /tmp directory. or you just set soap.wsdl_cache_enabled=0; and soap.wsdl_cache_ttl=0; PHP will fetch the wsdl file every-time you visit the page.

    0 讨论(0)
  • 2020-12-01 08:34

    if ujava's solution can't help you,you can try to use try/catch to catch this fatal,this works fine on me.

    try{
        $res = $client->__call('LineStopQueryJson',array('Parameters' => $params));
    }catch(SoapFault $e){
        print_r($client);
    }
    
    0 讨论(0)
提交回复
热议问题