RafaelX
RafaelX

Reputation: 41

PHP SoapClient Could not Connect to Host

This is a quite awkward I hope someone can help me figure out what is happenning with me. I did a small script just toconnect to a SoapServe. When I run it in the command line it works perfect.

But when I try to access it through the web broswer I got a "Could not connect to host" message.

So it's not a problem of resolving a host name as in the command line I can make it work, I think it has something related with the Apache configuration.

My code is simple as this:

try {
$client = new SoapClient("soap.wsdl");
$result = $client->ccReturn($params);
} catch (SoapFault $e) {
    print_r($e);
}

I really do not know what I am doing wrong! Please help!

Upvotes: 3

Views: 1860

Answers (1)

RafaelX
RafaelX

Reputation: 41

Problem solved!

With the help of this article: Php SoapClient stream_context option

I was thinking that the problem was something Apache-related, that does not allow my application to communication because when I manually run from the command-line the script worked.

Then I tried to connect to the SOAP website using CURL and the error message I got from CURL was: "Can't connect ... Permission Denied".

A small search and I run the extremely obvious command: "setsebool -P httpd_can_connect_network on" to configure SELinux policy.

Thanks to all that helped me here.

Upvotes: 1

Related Questions