Solved

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

Posted on 2010-09-23
26
2,299 Views
Last Modified: 2013-12-12
I had worked with RQuadling few days ago. Details are at the following link
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/SOAP/Q_26416747.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
0
Comment
Question by:caliea
  • 16
  • 10
26 Comments
 
LVL 40

Expert Comment

by:RQuadling
ID: 33747844
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.
0
 

Author Comment

by:caliea
ID: 33749459
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)
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33749602
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 ...
0
 

Author Comment

by:caliea
ID: 33750925
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
0
 

Author Comment

by:caliea
ID: 33785660
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.
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33787148
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?

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33787180
Can you use any other tool to talk to the web on the server from the commandline?

wget is such a tool

wget -d http://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

0
 

Author Comment

by:caliea
ID: 33791345

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

--2010-09-29 13:21:01--  http://www.experts-exchange.com/
Resolving www.experts-exchange.com... 64.156.132.140
Caching 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: 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="http://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 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 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(http://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]




0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33792277
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(http://www.e-e.com): failed to open stream: no suitable wrapper could be found in Command line code on line 1


With = 1, all OK.

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33792308
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.
0
 

Author Comment

by:caliea
ID: 33792971
# php -d allow_url_fopen=1 -r "echo file_get_contents('http://www.e-e.com');"
PHP Warning:  file_get_contents(http://www.e-e.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(http://www.e-e.com): failed to open stream: no suitable wrapper could be found in Command line code on line 1
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33793143
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].
0
 

Author Comment

by:caliea
ID: 33794008
Attached is the file containing output of the command:
php -i
info.txt
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 40

Expert Comment

by:RQuadling
ID: 33796750
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).
0
 

Author Comment

by:caliea
ID: 33800350
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(http://www.e-e.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(http://www.e-e.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(http://www.experts-exchange.com): failed to open stream: HTTP request failed!  in Command line code on line 1

6.  wget output is fine
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33803362
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');"

0
 
LVL 40

Accepted Solution

by:
RQuadling earned 500 total points
ID: 33803526
Can you read this PHP bug report : http://bugs.php.net/bug.php?id=40197

Could this be a firewall issue?

0
 

Author Comment

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

Warning: file_get_contents(http://www.e-e.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.
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33806532
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.

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33821296
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).
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33821313
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.

0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33821885
More feedback ...

If proxy is the issue, then ...

http://proxychains.sourceforge.net/



Not my forte unfortunately, I'm only passing on this one.
0
 

Author Comment

by:caliea
ID: 33828735
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.
0
 

Author Closing Comment

by:caliea
ID: 33828757
Richard Quadling never ever gives up and does not rest until the issue is solved. It is always a pleasure to work with Richard.
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33829883
Thank you for your great comment.
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33829924
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.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now