0

I'm trying to access a web service using PHP and SOAP (NuSoap library to be exact) but keep hitting the following error:

HTTP Error: Couldn't open socket connection to server http://rsvpdb01/CRMWebService prior to connect(). This is often a problem looking up the host name.

When accessing this service locally it was necessary to amend my hosts file to redirect the IP address to the 'rsvpdb01' location, however I'm not sure how to do the same on the web server (or if that will actually solve the problem).

The basics of my script are:

<?php
// Pull in the NuSOAP code
require_once('nusoap/lib/nusoap.php');
ini_set('soap.wsdl_cache_enabled',0);
ini_set('soap.wsdl_cache_ttl',0);

// Create the client instance
$action_authenticate = array('Action'=> 'http://tempuri.org/ICRMWebServiceAPI/AuthenticateUser');
$client = new SoapClient('http://81.144.199.11/CRMWebService?wsdl',$action_authenticate);
$client->soap_defencoding = 'UTF-8';

// Call the SOAP method
$result = $client->call('AuthenticateUser', array('Username' => 'username', 'Password' => 'password'));

// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';

// Check for a fault
if ($client->fault) {
    echo '<p><b>Fault: ';
    print_r($result);
    echo '</b></p>';
} else {

    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error

        echo '<p><b>Error: ' . $err . '</b></p>';
    } else {

        // Display the result
        print_r($result);
    }
}
?>

Could anybody shed any light on this?

  • Eventually solved this by finding the hosts file at the root of the Apache server and adding in the same host redirect. – Chris Knowles Jul 11 '14 at 14:55
  • Eventually or for sure? I'd say you're comment is right. Please extend it a bit, give an example and leave it as an answer below. You then can mark it as "the answer". This will mark your question answered & solved which is good for this website. You will also see that you'll gain some little reputation for that. If you've got any questions, please ask. – hakre Jul 15 '14 at 16:56
  • Thanks hakre, I did try to do this but couldn't at the time as a new user, so this was a good reminder – Chris Knowles Jul 17 '14 at 16:19

1 Answers1

0

The problem here was that the web service was pointing at a local machine and my server couldn't translate that physical address from the IP address I needed to use to connect.

I had to ask for root access on my hosting server so I could edit the 'hosts' file with the IP address against the local machine, it was a simple line to add like this:

123.456.5.1 xxxdb01