Search code examples
phpweb-servicessoapwsdl

php soapserver load external resources


i have a php soapserver running. it is written with the native php soap extension. This service loads a local file and handles it.

file_get_contents("C:/xampp/htdocs/test.xml");

but if i try to get a webserver file like this

file_get_contents("http://192.168.10.11/test.xml");

it doesnt work and the webservie returns "faild to load external entity http"

are there any restrictions in a php soapserver that i can't get file over http????

the actual problem is, that i want to call a webservice inside that soapserver. like a webservice chain... but this always fails with the above error message...

do you have any solutions for this?

Thanks a lot!


Solution

  • I like using curl:

    $curl_init = curl_init();
    curl_setopt($curl_init, CURLOPT_URL, 'http://example.com/test.xml');
    curl_setopt($curl_init, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl_init);
    

    I don't see why what you are doing shouldn't work though. Sometimes a server can be slow to close a connection... up to 90 seconds according to this post: PHP file_get_contents very slow when using full url

    You are sure the url is correct? Can you access it in the browser?