3

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);
}
Michael Bellamy
  • 543
  • 1
  • 8
  • 16

1 Answers1

3

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
  )
);
WEBjuju
  • 5,797
  • 4
  • 27
  • 36
  • Sorry, where there is $url is where I've just edited the code for stackoverflow and removed my url... I'll edit my code to correct it... – Michael Bellamy Nov 02 '16 at 22:09
  • but...that needs to be a valid wsdl url...$client = new SoapClient("some.wsdl"); – WEBjuju Nov 02 '16 at 22:13
  • has anything in this helped? http://stackoverflow.com/questions/12875409/soap-php-fault-parsing-wsdl-failed-to-load-external-entity – WEBjuju Nov 02 '16 at 22:15
  • Sorry WEB, I'm not making myself clear - I can't publish the WSDL on Stack Overflow for security reasons as I've signed an NDA so hence the reason I'm using http://example.com just to put the code on here to try get some help... – Michael Bellamy Nov 02 '16 at 22:15
  • i believe the issue is pulling in that wsdl. have you tried opening it with a local copy to be sure it isn't an ssl or other socket issue? – WEBjuju Nov 02 '16 at 22:21
  • Thanks for your help, but I'm not entirely sure what you mean. This is the first web service I've tried to connect to and for some reason it runs great connecting to it from my localhost but when I upload this php file online that's when I get the error. – Michael Bellamy Nov 02 '16 at 22:25
  • 1
    Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/127229/discussion-between-webjuju-and-michael-bellamy). – WEBjuju Nov 02 '16 at 22:25