Hey Guys,
I'm trying to get a script working that will accept HTTP POST data from a client. The data is proprietary and is based on UTF197/TCS.
I'm running IIS 6 on Windows 2003. As far as i can see it should be working.
.php is allowing "All" verbs.
I have even created a MIME type for .tcs files that is then associated with the my index.php file. (i think that this is irrelevant but i'm flailing here). And i see that in the error message that they receive the Content-Type is text/html.
Why would my client be receiving the message:
RECV MESSAGE HEADER HTTP/1.1 405 Method Not Allowed
Allow: OPTIONS, TRACE, GET, HEAD
Content-Length: 1564
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Tue, 30 Sep 2008 20:59:44 GMT
How do i allow POST? As i mentioned .php is allowing "All" verbs in the IIS config.
They are using a terminal to send this data. Anyone have an idea on how to emulate this using .php scripts to send the data? I have created a few php forms that use HTTP POST to submit the data but they don't have any issues.
Below is an example of one of my flailing scripts for what it matters. All i'm trying to do here is capture the data and bounce it back to them:
Thanks in advance,
dean
<?php
function firstRun()
{
if (!isset($_POST['submit']))
return true;
}
function secondRun()
{
//$data = file_get_contents('php://input');
// $fp = fopen('php://input','r');
// while (!feof($fp))
// echo fgets($fp);
// fclose($fp);
//print $data;
$string = "see it: \r\n";
$string = $string . "data snippet: " . $_POST['dataSnippet'] . "<br />";
$string = $string . "string length: " . strlen($_POST['dataSnippet']) . "<br />";
$string = $string . "RAW_POST_DATA: " . $GLOBALS['HTTP_RAW_POST_DATA'] . "<br />";
print $string;
//$data = file_get_contents('php://input');
$data1 = $GLOBALS['HTTP_RAW_POST_DATA'];
//$phpInput = "phpInput is: " . $data . "\r\n";
//$RAW_POST = "RAW_POST is: " . $data1 . "\r\n";
//print $phpInput;
//print $RAW_POST;
//$data = $phpInput . $RAW_POST;
$unixTime = time();
$filename = "transactions/trn" . $unixTime . ".trm";
$fhandle = fopen($filename, 'w');
fwrite($fhandle, $string);
fclose($fhandle);
$fileExistTestHandler = fopen($filename, 'r'); //check if backup of transaction was created successfully;
$fileExistTest = $fileExistTestHandler;
fclose($fileExistTestHandler);
}
function snippetForm()
{
?>
<form id="datasnippet" method="post" action="terminal_DataPost.php" content-type="UTF197/TCS" content-length="4">
<table align="center">
<tr>
<td>
Data Snippet:
</td>
</tr>
<tr>
<td>
<textarea cols="25" rows="3" name="dataSnippet"></textarea>
</td>
<tr>
<td></td>
<td>
<input type="hidden" name="submit" value="1" />
<input type="submit" name="submitButton" value="Submit" />
</td>
</tr>
</table> </form><br />
<?php
}
?>