No POST-Data available in Script when Handling ErrorDocument 404

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I wrote a scritpt for testing SOAP-Services. It generates and sends requests to other machines but also receives such requests from other machines in the net.As there are many 'senders' and muc more URL's they are sending their requests to, I intended to write a general SOAP-Request handler, that handles all incoming requests.

Therefore I Configured Apache 2.0.55 using the ErrorDocument directive:

ErrorDocument 404 /soap/dispatcher.php

Now my tool is able to handle SOAP-Requests to any URL that is located on the Server e.g. (ServerName = spttt.seraph)

http://spttt.seraph/bli/blo/foo (but also)
http://spttt.seraph/sifdino/services/OrderEntryRequestService

Hope you got the it so far.

Now my problem:
The Soap-Rquest handler needs to read the POST-Data that the sender of the SOAP-Request posted to the script. $HTTP_RAW_POST_DATA should contain this data but also php://input was mentioned in some php-mailing-list messages I found in the archives. My problem is, that my script NEVER gets any POST-Data, if it is called by the ErrorDocument 404 Rule. If I address the handler directly, the Post-Data ist there.

When the script is called by the apache errorDocument handler, the following headers are received:

HTTP/1.1 404 Not Found
Date: Sun, 08 Jan 2006 00:48:45 GMT
Server: Apache/2.0.55 (Win32) PHP/5.1.1 DAV/2
X-Powered-By: PHP/5.1.1
Set-Cookie: PHPSESSID=0q9amr3s44k54i4lrv3no221k3; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Status: 200 OK
Content-Length: 1574
Content-Type: text/html; charset=ISO-8859-1


Array
(
    [REDIRECT_REQUEST_METHOD] => POST
    [REDIRECT_STATUS] => 404
    [HTTP_HOST] => spttt.seraph
    [CONTENT_TYPE] => text/xml
    [CONTENT_LENGTH] => 25
[PATH] => C:\Programme\texmf\miktex\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\cvsnt;C:\Programme\Microsoft SQL Server\80\Tools\BINNC:\Programme\Gemeinsame Dateien\Ulead Systems\MPEG;C:\Programme\Ulead Systems\Ulead FilmBrennerei 2 SE;C:\Programme\MySQL\MySQL Server 4.1\bin;C:\Programme\Subversion\bin;C:\Programme\QuickTime\QTSystem\
    [SystemRoot] => C:\WINDOWS
    [COMSPEC] => C:\WINDOWS\system32\cmd.exe
    [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
    [WINDIR] => C:\WINDOWS
[SERVER_SIGNATURE] => <address>Apache/2.0.55 (Win32) PHP/5.1.1 DAV/2 Server at spttt.seraph Port 80</address>

    [SERVER_SOFTWARE] => Apache/2.0.55 (Win32) PHP/5.1.1 DAV/2
    [SERVER_NAME] => spttt.seraph
    [SERVER_ADDR] => 192.168.44.100
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 192.168.44.100
    [DOCUMENT_ROOT] => D:/projects/spttt/html
    [SERVER_ADMIN] => webmaster@xxxxxxxxxxxxxxxxxxxxxx
    [SCRIPT_FILENAME] => D:/projects/spttt/html/soap/dispatcher.php
    [REMOTE_PORT] => 1863
    [REDIRECT_URL] => /sptdino/services/OrderEntryRequestService
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] =>
    [REQUEST_URI] => /sptdino/services/OrderEntryRequestService
    [SCRIPT_NAME] => /soap/dispatcher.php
    [PHP_SELF] => /soap/dispatcher.php
    [REQUEST_TIME] => 1136681325
)

Notice the REQUEST_METHOD, which is GET! Obviously the script get's no POST-DATA in a GET-Request...

- Can anyone tell, if this behaviour is by intention?
- Why are the POST-Data not handed to the ErrorDocument - Script?
- Is there a possibility to solve this (workaround)?
- Im I stupid?

Below further information an my test-scripts:

Regards & thanks
Oli



Apache httpd.conf

<VirtualHost *:80>
    ServerAdmin webmaster@xxxxxxxxxxxxxxxxxxxxxx
    DocumentRoot D:/projects/spttt/html
    ErrorDocument 404 /soap/dispatcher.php
    ServerName spttt.seraph
    ErrorLog logs/spt-error_log
    CustomLog logs/spt-access_log common
</VirtualHost>

/soap/dispatcher.php (target for the ErrorDocument 404 directive)

<?php
header("Status:200 OK");
print_r($_SERVER);
$HTTP_RAW_POST_DATA = file_get_contents("php://input");
echo $HTTP_RAW_POST_DATA;
exit;
?>

posttest2.php (sends a POST-Request to an unknown URL on the Server which should then be forwarded to the dispatcher.php by Apache errorDocument-Handler)

<?php
$post_msg = '<request><bla/></request>';
$http_msg = "POST /sptdino/services/OrderEntryRequestService HTTP/1.1\r\n";
$http_msg .= "Host: spttt.seraph\r\n";
$http_msg .= "Content-Type: text/xml\r\n";
$http_msg .= "Content-Length:" .strlen($post_msg). "\r\n\r\n";
$http_msg .= $post_msg ."\r\n";
$http_msg;

$errno;
$errdesc;

$fp = @fsockopen("192.168.44.100", 80,$errno, $errdesc,15);

$reply = "";

if ($fp)
{
    fputs ($fp, $http_msg);
    while (!feof($fp))
    {
        $reply .= fgets($fp, 1024);
    }
    fclose ($fp);
}

echo($reply);
print_r($errdesc);
echo "done";
?>

Apache error-log states:

[Sun Jan 08 03:08:15 2006] [error] [client 192.168.44.100] File does not exist: D:/projects/spttt/html/sptdino

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux