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?