Link to home
Start Free TrialLog in
Avatar of caliea
caliea

asked on

Trouble having initiating SOAP request in PHP on Linux (works in win xp environment)

I had worked with RQuadling few days ago. Details are at the following link
https://www.experts-exchange.com/questions/26416747/Trouble-receiving-WebService-SOAP-XML-response-in-PHP.html

The program works fine on a WIn XP system.
  It is not running on a CentOS linux server.
I installed the php-soap package on the linux server as follows:
 yum install php-soap
 (Then restarted apache. Even restarted the server)
I have the following 2 files in the /var/www/html/topup folder in the Linux server:
ServiceManager.php
topup6.php

These two files are attached  ServiceManager.php ServiceManager.php topup6.php

I run the program as follows:
http://<ip addr of linux server>/topup/topup6.php

when I run the program, I do not see anything displayed in the browser window.
I ran wireshark and there is NO communication related to soap calls - the soap requests are not being sent out.
The same program works fine from my winxp system.

Please review and advise.
Thanks
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Can you add ...

<?php
error_reporting(-1); // Show everything going wrong.
ini_set('display_errors', 1); // Display them.
set_time_limit(0); // Take forever.


to the top of the topup6.php script.

And then can you run it from the command line.

Can you also edit the php.ini file so that ...

display_startup_errors = 1

Now, we will see if there are any startup errors which would be missed from a web interface.
Avatar of caliea
caliea

ASKER

I put in the above and get the following output on the console:

*********** Console Output ***********
[root@asterisk1 topup]# php -f "topup6.php"
lPHP Warning:  SoapClient::__construct(http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL): failed to open stream: HTTP request failed!  in /var/www/html/topup/ServiceManager.php on line 234

Warning: SoapClient::__construct(http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL): failed to open stream: HTTP request failed!  in /var/www/html/topup/ServiceManager.php on line 234
PHP Warning:  SoapClient::__construct(): I/O warning : failed to load external entity "http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL" in /var/www/html/topup/ServiceManager.php on line 234

Warning: SoapClient::__construct(): I/O warning : failed to load external entity "http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL" in /var/www/html/topup/ServiceManager.php on line 234
PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL' in /var/www/html/topup/ServiceManager.php on line 234
Request Headers
---------------
PHP Notice:  Undefined variable: sm in /var/www/html/topup/topup6.php on line 56

Notice: Undefined variable: sm in /var/www/html/topup/topup6.php on line 56
PHP Fatal error:  Call to a member function __getLastRequestHeaders() on a non-object in /var/www/html/topup/topup6.php on line 56

Fatal error: Call to a member function __getLastRequestHeaders() on a non-object in /var/www/html/topup/topup6.php on line 56
[root@asterisk1 topup]#
*******************************************************************
I have the following settings in php.ini
allow_url_fopen = On
; user_agent="PHP"    
(The user_agent setting is commented out. In the WIn XP system, where this script runs successfully, have the same settings)
So, it looks like there is a block between the PHP request and the host.

At the command prompt can you type ...

php -r "echo file_get_contents('http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL');"

I get the wsdl file.

At this stage, I'm guessing it isn't PHP that's the issue, but the server setup.

And I'm a Windows guy ...
Avatar of caliea

ASKER

Your analysis is correct. The linux server is blocking the PHP request.
We are reviewing the configuration of the Linux server.
Please standby while we resolve this network config issue on our linux server
Avatar of caliea

ASKER

We did a fresh install of linux on a server, disabled the firewall, installed the php package, php soap addon and are having the same problem.

php -r "echo file_get_contents('http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL');"
PHP Warning:  file_get_contents(http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL): failed to open stream: HTTP request failed!  in Command line code on line 1


However we are able to use the browser to browse various sites.
Please advise.
Hmm.

I don't know unix/lunix at all at this level.

But, if it was windows, I'd now be running Wireshark to see if my requests are even getting to the network. I don't know which end of the connection is doing the blocking.

Can you use PHP to talk to ANY site?

php -r "echo file_get_contents('http://www.experts-exchange.com');"

for example?

Can you also try ...

php -n -r "echo file_get_contents('http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL');"

Is there a non-standard setting in your config getting in the way?

Can you use any other tool to talk to the web on the server from the commandline?

wget is such a tool

wget -d https://www.experts-exchange.com

output below.
DEBUG output created by Wget 1.12 on cygwin.

URI encoding = `UTF-8'
--2010-09-29 10:32:28--  http://www.experts-exchange.com/
Resolving www.experts-exchange.com (www.experts-exchange.com)... 64.156.132.140
Caching www.experts-exchange.com => 64.156.132.140
Connecting to www.experts-exchange.com (www.experts-exchange.com)|64.156.132.140|:80... connected.
Created socket 3.
Releasing 0x00902fa0 (new refcount 1).

---request begin---
GET / HTTP/1.0
User-Agent: Wget/1.12 (cygwin)
Accept: */*
Host: www.experts-exchange.com
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 200 OK
Via: 1.1 BV-VM-SVR-17
Connection: Keep-Alive
Proxy-Connection: Keep-Alive
Content-Length: 58033
Date: Wed, 29 Sep 2010 09:34:11 GMT
Content-Type: text/html;charset=UTF-8
Server: Apache-Coyote/1.1
Set-Cookie: EETABBEDMENU=; Domain=.experts-exchange.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: JSESSIONID=93DA802D60A349F8B34588E1EC06F7AA; Path=/
Set-Cookie: JSESSIONID=93DA802D60A349F8B34588E1EC06F7AA; Domain=.experts-exchange.com; Path=/
Cache-Control: private
P3P: policyref="http://www.experts-exchange.com/policies/p3p.xml", CP="NOI IVA IVD OUR IND UNI"
X-Cache: MISS from www.experts-exchange.com
Keep-Alive: timeout=3, max=10000

---response end---
200 OK
cdm: 1 2 3 4 5 6 7 8
Stored cookie www.experts-exchange.com -1 (ANY) / <session> <insecure> [expiry none] JSESSIONID 93DA802D60A349F8B34588E1EC06F7AA
cdm: 1 2 3 4 5 6 7 8
Stored cookie experts-exchange.com -1 (ANY) / <session> <insecure> [expiry none] JSESSIONID 93DA802D60A349F8B34588E1EC06F7AA
Registered socket 3 for persistent reuse.
URI content encoding = `UTF-8'
Length: 58033 (57K) [text/html]
Saving to: `index.html.4'

100%[==============================================================================================================================================================>] 58,033      73.3K/s   in 0.8s

2010-09-29 10:32:29 (73.3 KB/s) - `index.html.4' saved [58033/58033]

Open in new window

Avatar of caliea

ASKER


Test 1 - Output of wget
===================
# wget -d https://www.experts-exchange.com
DEBUG output created by Wget 1.11.4 Red Hat modified on linux-gnu.

--2010-09-29 13:21:01--  https://www.experts-exchange.com/
Resolving https://www.experts-exchange.com... 64.156.132.140
Caching https://www.experts-exchange.com => 64.156.132.140
Connecting to www.experts-exchange.com|64.156.132.140|:80... connected.
Created socket 3.
Releasing 0x0952af48 (new refcount 1).

---request begin---
GET / HTTP/1.0
User-Agent: Wget/1.11.4 Red Hat modified
Accept: */*
Host: https://www.experts-exchange.com
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response...
---response begin---
HTTP/1.1 200 OK
Date: Wed, 29 Sep 2010 17:21:10 GMT
Server: Apache-Coyote/1.1
Set-Cookie: EETABBEDMENU=; Domain=.experts-exchange.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
Set-Cookie: JSESSIONID=EEDB2FFC0A1661FAFEA3E2931CAF7889; Path=/
Set-Cookie: JSESSIONID=EEDB2FFC0A1661FAFEA3E2931CAF7889; Domain=.experts-exchange.com; Path=/
Cache-Control: private
P3P: policyref="https://www.experts-exchange.com/policies/p3p.xml", CP="NOI IVA IVD OUR IND UNI"
Content-Type: text/html;charset=UTF-8
Content-Length: 58181
X-Cache: MISS from https://www.experts-exchange.com
Keep-Alive: timeout=3, max=10000
Connection: Keep-Alive

---response end---
200 OK
Registered socket 3 for persistent reuse.
cdm: 1 2 3 4 5 6 7 8
Stored cookie https://www.experts-exchange.com -1 (ANY) / <session> <insecure> [expiry none] JSESSIONID EEDB2FFC0A1661FAFEA3E2931CAF7889
cdm: 1 2 3 4 5 6 7 8
Stored cookie experts-exchange.com -1 (ANY) / <session> <insecure> [expiry none] JSESSIONID EEDB2FFC0A1661FAFEA3E2931CAF7889
Length: 58181 (57K) [text/html]
Saving to: `index.html'

100%[=======================================================>] 58,181      29.2K/s   in 1.9s

2010-09-29 13:21:04 (29.2 KB/s) - `index.html' saved [58181/58181]

Test 2 - Output of php command line
=============================
# php -r "echo file_get_contents('http://www.experts-exchange.com');"
PHP Warning:  file_get_contents(https://www.experts-exchange.com): failed to open stream: HTTP request failed!  in Command line code on line 1
[WIRESHARK does NOT ahow any network activiy from the linux server after the above command is issued]


Test 3
=====
# php -n -r "echo file_get_contents('http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL');"

Warning: file_get_contents(http://stage.valuetopup.com/posaservice/servicemanager.asmx?WSDL): failed to open stream: HTTP request failed!  in Command line code on line 1
#
[WIRESHARK does NOT ahow any network activiy from the linux server after the above command is issued]




Hmmm.

So, firewall wise, everything is OK.

No activity in Wireshark firmly plants the blame with PHP.

Hmm..

Can you try this ...

php -d allow_url_fopen=1 -r "echo file_get_contents('http://www.e-e.com');"

If I set the value to 0, on my setup (PHP 5.3.2), I get ...


php -d error_reporting=-1 -d display_errors=1 -d display_startup_errors=1 -d allow_url_fopen=0 -r "echo file_get_contents('http://www.e-e.com');"

Warning: file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in Command line code on line 1

Warning: file_get_contents(https://www.experts-exchange.com): failed to open stream: no suitable wrapper could be found in Command line code on line 1


With = 1, all OK.

http://php.net/manual/en/function.fopen.php ...

"If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail."

The note above applies to all fopen style functions.
Avatar of caliea

ASKER

# php -d allow_url_fopen=1 -r "echo file_get_contents('http://www.e-e.com');"
PHP Warning:  file_get_contents(https://www.experts-exchange.com): failed to open stream: HTTP request failed!  in Command line code on line 1
(This works fine on windows system)

# php -d allow_url_fopen=0 -r "echo file_get_contents('http://www.e-e.com');"
PHP Warning:  file_get_contents(): URL file-access is disabled in the server configuration in Command line code on line 1
PHP Warning:  file_get_contents(https://www.experts-exchange.com): failed to open stream: no suitable wrapper could be found in Command line code on line 1
Hmm..

So not allow_url_fopen.

Can you send me the output to

php -i

please.

If you have any private values set there (username, passwords, etc.) can you replace them with [EDITED].
Avatar of caliea

ASKER

Attached is the file containing output of the command:
php -i
info.txt
I see nothing untoward there.

I've placed a question on the PHP General list - http://news.php.net/php.general/308364

I'll keep you informed.

Are you able to reinstall PHP without the SOAP element and try the command line tests?

You are using PHP 5.1.6. If you could upgrade PHP to the latest version (I use a dev release of 5.3.4-dev, so 5.3.3 is the last official release).
Avatar of caliea

ASKER

1. Removed php-soap
     yum erase php-soap
    ==================
     Running Transaction
       Erasing        : php-soap                                                 1/1

       Removed:
        php-soap.i386 0:5.1.6-27.el5

     Complete!

2. Attempted to update PHP
     Package php-5.1.6-27.el5.i386 already installed and latest version
        Nothing to do

3.   php -d allow_url_fopen=1 -r "echo file_get_contents('http://www.e-e.com');"
      =============================================================
PHP Warning:  file_get_contents(https://www.experts-exchange.com): failed to open stream: HTTP request failed!  in Command line code on line 1
(NO Activity in Wireshark)

4. php -d allow_url_fopen=0 -r "echo file_get_contents('http://www.e-e.com');"
   ==============================================================
PHP Warning:  file_get_contents(): URL file-access is disabled in the server configuration in Command line code on line 1
PHP Warning:  file_get_contents(https://www.experts-exchange.com): failed to open stream: no suitable wrapper could be found in Command line code on line 1

5.    php -r "echo file_get_contents('http://www.experts-exchange.com');"
       =======================================================
 php -r "echo file_get_contents('http://www.experts-exchange.com');"
PHP Warning:  file_get_contents(https://www.experts-exchange.com): failed to open stream: HTTP request failed!  in Command line code on line 1

6.  wget output is fine
Can you try adding the -n option? Let's take out all the ini files (that's what -n does).

So ...

php -n -d allow_url_fopen=1 -r "echo file_get_contents('http://www.e-e.com');"

ASKER CERTIFIED SOLUTION
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of caliea

ASKER

# php -n -d allow_url_fopen=1 -r "echo file_get_contents('http://www.e-e.com');"

Warning: file_get_contents(https://www.experts-exchange.com): failed to open stream: HTTP request failed!  in Command line code on line 1


I will place the server outside the firewall and do the test. Please give me a day or so to arrange for this test.
Certainly. I'm still surprised that Wireshark doesn't record anything for the php request. I'd expect that as it would be the firewall bouncing the request.

Good luck.

If this isn't the issue, then I think you'll need to request attention and ask to include zones relating to CentOS and PHP Installation.

If the firewall IS in the way, then you need to route the calls through the firewall.

I had a similar issue with PHP on a windows network using NTLM authentication.

Couldn't do the NTLM authentication in PHP, so used the NTLMAPS (NTLM Authentication Proxy Server) - a Python based proxy from Sourceforge (http://ntlmaps.sourceforge.net/). Added a few patches to keep the credentials secure.

If this is the case, take a look at my user note http://docs.php.net/manual/en/function.stream-context-get-default.php#72086

This may help. The code shown was used for several years before we changed our network.

On windows, the default gateway, as reported by IPCONFIG /all, is now correct and we don't have NTLM authentication. Instead we have Active Directory doing it for us, so the firewall knows we are authenticated users (I think - I'm not a sysop).
If setting the context works for file_get_contents(), but NOT for soap, then add ...

'stream_context' => stream_context_get_default ()

to the options of the soap request.

More feedback ...

If proxy is the issue, then ...

http://proxychains.sourceforge.net/



Not my forte unfortunately, I'm only passing on this one.
Avatar of caliea

ASKER

Hello Richard:
I put the linux server completely outside the firewall and it works file. I have the SonicWall as the firewall. The WinXP is also behind the same firewall and does not have the issue. The linux server does.

 Your comment is the box 09/30/10 05:03 PM, ID: 33803526 has resolved the problem.

Thankyou very much for your help in resolving this issue.
Avatar of caliea

ASKER

Richard Quadling never ever gives up and does not rest until the issue is solved. It is always a pleasure to work with Richard.
Thank you for your great comment.
And for the record, the firewall issue was highlighted by Adam Richardson and Kranthi Krishna on the PHP General Mailing List.

I was just acting as a conduit.