Michael Bellamy Michael Bellamy - 1 month ago 12
PHP Question

Connecting to web service using SOAP & PHP

I'm trying to connect to a web service using PHP's soap client which I can successfully do using Visual Studio, pressing F5 and running the page locally which works a treat.

As soon as I upload the exact same file to my apache web host, I keep getting the error: "failed to load external entity".

Here's my code with the credentials and url taken out...

Any ideas?

<?php
header("Access-Control-Allow-Origin: http://example.com");
header("Access-Control-Request-Method: GET,POST");

ini_set('display_errors', true);
ini_set("soap.wsdl_cache_enabled", "0");
error_reporting(E_ALL);


try
{
$soapclient = new SoapClient('http://example.com');

$params = array ('SystemID' => 'testID','Username' => 'test', 'Password' => 'test');

$response = $soapclient->GetEngineerList($params);

print_r($response);

}
catch(SoapFault $e)
{
print_r($e);
}

Answer

strings are not read twice and parsed in single quotes

$soapclient = new SoapClient('$url');

try

$soapclient = new SoapClient($url);

also...do you have $url = ''; anywhere?

UPDATE 1

please try using basic auth to get to your wsdl:

$login = 'bert';
$password = 'berts password';

$client = new SoapClient(
  'http://' . urlencode($login) . ':' . urlencode($password) . '@www.server.com/path/to/wsdl',
  array(
    'login' => $login,
    'password' => $password
  )
);