Link to home
Start Free TrialLog in
Avatar of X_Kalibur
X_Kalibur

asked on

HTTP_RAW_POST_DATA - non existant

Howdy all

I'm trying to use the NuSOAP library to create an XML-RPC server and then query that using a client.

In reading one of the million tutorials on the issue, it never mentioned the fact that the HTTP_RAW_POST_DATA was even mildly important....

So to cut a long story short, i've now done my research and set the "always_populate_raw_post_data = On" directive in php.ini, but am still having a problem, where the HTTP_RAW_POST_DATA is not defined

So what can i do?! i'd like to get this going asap, or i'll move over to a more productive platform (Delphi/Kylix)...I like PHP because its already 100% cross platform compatible, whereas Delphi/Kylix still needs some tip-toeing

Thanks!

-Xerxes
Avatar of X_Kalibur
X_Kalibur

ASKER

Output from phpinfo()....

----------

PHP Variables

Variable Value
_SERVER["AUTH_TYPE"] Basic  
_SERVER["DOCUMENT_ROOT"] /var/www/htdocs  
_SERVER["HTTP_ACCEPT"] image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*  
_SERVER["HTTP_ACCEPT_LANGUAGE"] en-au  
_SERVER["HTTP_CACHE_CONTROL"] max-age=259200  
_SERVER["HTTP_CONNECTION"] keep-alive  
_SERVER["HTTP_HOST"] xerxesb.no-ip.org  
_SERVER["HTTP_USER_AGENT"] Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461)  
_SERVER["HTTP_VIA"] 1.0 smokescreen.dataforce.com.au:3128 (Squid/2.4.STABLE3)  
_SERVER["HTTP_X_FORWARDED_FOR"] 192.168.1.101  
_SERVER["PATH"] /sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin  
_SERVER["REMOTE_ADDR"] 203.63.31.130  
_SERVER["REMOTE_PORT"] 1487  
_SERVER["REMOTE_USER"] xerxes  
_SERVER["SCRIPT_FILENAME"] /var/www/htdocs/source/phpinfo2/phpinfo.php  
_SERVER["SERVER_ADDR"] 192.168.0.200  
_SERVER["SERVER_ADMIN"] xerxes.d.battiwalla@uts.edu.au  
_SERVER["SERVER_NAME"] xerxesb.no-ip.org  
_SERVER["SERVER_PORT"] 80  
_SERVER["SERVER_SIGNATURE"] <ADDRESS>Apache/1.3.23 Server at xerxesb.no-ip.org Port 80</ADDRESS>
 
_SERVER["SERVER_SOFTWARE"] Apache/1.3.23 (Unix) (Red-Hat/Linux) mod_ssl/2.8.7 OpenSSL/0.9.6b DAV/1.0.3 PHP/4.2.2 mod_perl/1.26  
_SERVER["GATEWAY_INTERFACE"] CGI/1.1  
_SERVER["SERVER_PROTOCOL"] HTTP/1.0  
_SERVER["REQUEST_METHOD"] GET  
_SERVER["QUERY_STRING"]  
_SERVER["REQUEST_URI"] /source/phpinfo2/phpinfo.php  
_SERVER["SCRIPT_NAME"] /source/phpinfo2/phpinfo.php  
_SERVER["PATH_TRANSLATED"] /var/www/htdocs/source/phpinfo2/phpinfo.php  
_SERVER["PHP_SELF"] /source/phpinfo2/phpinfo.php  
could you use a basic HTML FORM that has action=source/phpinfo2/phpinfo.php and method=POST and containing some non-empty fields.

This way I think you'll see $*POST_VARS* ;-)

Here, you did a GET : _SERVER["REQUEST_METHOD"] GET  
No marvel that POST_VARS is empty 8-))))
Hi VGR,

This is the article i followed to try and get it all working:

http://www.zend.com/zend/tut/tutorial-campbell.php#Heading7

Now if i visit the URL of the SOAP server given in the example ( http://www.whytewolf.ca/ws/taxCalc.php ), it returns a proper XML document.

but when i try to visit my implementation of the server, i'm getting the "Undefined Index: HTTP_RAW_POST_DATA", and a malformed XML document, because of PHP injecting this error


NOW.....interestingly enough, if i visit my php CLIENT implementation of the web service, it works fine! it returns output as expected.

So this is pretty weird behviour, unless i am totally mistaken


Whats going on!?!
This is the error message coming from my server, if i try to view the server.php file directly:


<b>Notice</b>:  Undefined index:  HTTP_RAW_POST_DATA in <b>/var/www/htdocs/source/webservices/server.php</b> on line <b>58</b><br />
and here is a copy of the source code....
--------------


<?php
/**
* taxCalc.php
* An example PHP script which uses NuSOAP to provide a
* tax calculator function.
*
* Created on August 7, 2002, 6:11 PM
* @author  Sean Campbell
* @version 1.0
*/

/* Include the NuSOAP library. */
require_once('nusoap.php');  

/* Create a new SOAP server instance. */
$server = new soap_server;

/* Register the taxCalc function for publication. */
$server->register('taxCalc');  

/**
* Calculates the total (including tax) for a purchase based on the
* rate and subtotal provided.
*
* @param string $rate          The tax rate in percent.
* @param string $sub           The subtotal for the purchase.
*
* @return float $total            The total for the purchase.
*
* @author  Sean Campbell
* @version 1.0
*/
function taxCalc ($rate, $sub)
{
    if ($rate == '' || $rate <= 0) {
        /* Return a SOAP fault indicating a negative or
         * zero tax rate was transmitted. */
        return new soap_fault(
            'Client', '',
            'Must supply a positive, non-zero tax rate.',''
        );
    }

    if ($sub == '' || $sub <= 0) {
        /* Return a SOAP fault indicating a negative or
     * zero subtotal was transmitted. */
        return new soap_fault(
            'Client', '',
            'Must supply a positive, non-zero subtotal.', ''
        );
    }
     
    /* Return the generated total for the purchase. */
    return (($rate / 100) * $sub) + $sub;  
}  

/* Begin the HTTP listener service and exit. */
//
//
// !!!!!!!!!THIS IS THE CULPRIT LINE!!!!!!!!!!!
$server->service($GLOBALS["HTTP_RAW_POST_DATA"]);

exit();
?>
Sorry, I can't help you.
First it's SOAP which I never use
Then HTTP_RAW_POST_DATA I never saw, I use HTTP_POST_VARS

My guess is that the server implementation is different from what you call "client side impl." in that the configuration of the web server are different.

good luck
and here is a copy of the source code....
--------------


<?php
/**
* taxCalc.php
* An example PHP script which uses NuSOAP to provide a
* tax calculator function.
*
* Created on August 7, 2002, 6:11 PM
* @author  Sean Campbell
* @version 1.0
*/

/* Include the NuSOAP library. */
require_once('nusoap.php');  

/* Create a new SOAP server instance. */
$server = new soap_server;

/* Register the taxCalc function for publication. */
$server->register('taxCalc');  

/**
* Calculates the total (including tax) for a purchase based on the
* rate and subtotal provided.
*
* @param string $rate          The tax rate in percent.
* @param string $sub           The subtotal for the purchase.
*
* @return float $total            The total for the purchase.
*
* @author  Sean Campbell
* @version 1.0
*/
function taxCalc ($rate, $sub)
{
    if ($rate == '' || $rate <= 0) {
        /* Return a SOAP fault indicating a negative or
         * zero tax rate was transmitted. */
        return new soap_fault(
            'Client', '',
            'Must supply a positive, non-zero tax rate.',''
        );
    }

    if ($sub == '' || $sub <= 0) {
        /* Return a SOAP fault indicating a negative or
     * zero subtotal was transmitted. */
        return new soap_fault(
            'Client', '',
            'Must supply a positive, non-zero subtotal.', ''
        );
    }
     
    /* Return the generated total for the purchase. */
    return (($rate / 100) * $sub) + $sub;  
}  

/* Begin the HTTP listener service and exit. */
//
//
// !!!!!!!!!THIS IS THE CULPRIT LINE!!!!!!!!!!!
$server->service($GLOBALS["HTTP_RAW_POST_DATA"]);

exit();
?>
Are you using the correct sort of client?

I have installed nusoap on my wintel box and use the following script ...

<html>
<head>
<title>Tax calculator Client</title>
</head>
<body>
<h1>Tax calculated:</h1>
<?php
/**
* taxCalcClient.php
* An example PHP script which uses NuSOAP to access
* a tax calculator function.
*
* Created on August 7, 2002, 6:11 PM
* @author  Sean Campbell
* @version 1.0
*/

/* Include the NuSOAP library. */
require_once('./lib/nusoap.php');

/* Initialize the client's parameter list. */
$param = array('rate' => $_GET['rate'],  
               'sub' => $_GET['sub']
               );

/* Create a new client by providing the endpoint to the
* constructor. */
$client = new soapclient(
                    'http://www.whytewolf.ca/ws/taxCalc.php'
                    );

/* Call the taxCalc() function, passing the parameter list. */
$response = $client->call('taxCalc', $param);

/*  handle any SOAP faults. */
if ($client->fault) {
    echo "FAULT: <p>Code: {$client->faultcode}<br />";
    echo "String: {$client->faultstring}";
} else {
    echo "$" . $response;
}
?>
</body>
</html>

calling ...

taxcalcclient.php?rate=17.5&sub=100

and I get back ...

Tax calculated:
$117.5

which is correct.

If you get this working, then the class is installed correctly and is working as a client.

Richard.
I am trying it locally and getting ...

<html>
<head>
<title>Tax calculator Client</title>
</head>
<body>
<h1>Tax calculated:</h1>
$
</body>
</html>

Which is better than an error! But only just!.

RQuadling - thats what i get from the client, too!

have you tried visiting the page for your server directly - it shoiuld return a botched up XML document.
hello!?

anyone got further advice?!
If I call the taxcalc.php file directly (rather than through the client), I get ...

<b>Notice</b>:  Undefined index:  HTTP_RAW_POST_DATA in <b>C:\Personal\WebSites\PFL\public_html\taxcalc.php</b> on line <b>61</b><br />

Which is not good!

Hmmmm.

Try removing _RAW ?

Richard.
Richard,

AFAIK and from what i've read, it needs to use the HTTP_RAW_POST_DATA to extract the SOAP XML from the http request.


But the behaviour you just described is exactly what i'm getting!


*sigh*

i wonder wtf is going on? possibly register_globals??


-Xerxes
Nope.

What I would like to know is what is the format of HTTP_RAW_POST_DATA?

$HTTP_POST_VARS / $_POST or $HTTP_GET_VARS / $_GET ?

I cannot find any references to HTTP_RAW_POST_DATA that have not been discussed here.

How about emailing the original code writer?

Richard.
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America 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
In my PHP.INI file ...

; Always populate the $HTTP_RAW_POST_DATA variable.
always_populate_raw_post_data = On

Not sure if this is on for all servers.

Richard.