2

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!

RafaelX
  • 31
  • 4
  • See if this helps... http://stackoverflow.com/questions/4318870/soapfault-exception-could-not-connect-to-host – Shankar Narayana Damodaran May 06 '14 at 04:45
  • Thanks, I've seen this one before...didn't help – RafaelX May 06 '14 at 05:38
  • This could be caused by any number of things, such as firewalls and proxies. Try searching through the wsdl for the **soap:address** locations. It could be that a server name is given that the machine you are running your code on does not have access to. Could be that you need to add something to your hosts file to gain access – codeguerrilla May 06 '14 at 05:51
  • That's not the case, because when I run from the command line I can get all the responses. – RafaelX May 06 '14 at 15:32

1 Answers1

1

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.

Community
  • 1
  • 1
RafaelX
  • 31
  • 4