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
}
?>

    I wish IIS had a proper configuration file instead of masses of dialogue boxes; but the short answer is that this is a server configuration thing rather than a problem with the script itself. Unfortunately I left my IIS days behind years ago and all I can remember of it was that it was a hassle to get anything set up. I recall that there is some sort of hierarchical structure so that you could set up more generic configurations, and then override them for more specialised purposes: is there a higher-level setting forcing that list of allowed methods that your problematic configuration happens to be inheriting?

    Content-Type: text/html

    That's just the MIME type of the 405 message itself, not something to worry about.

      Hey Weedpacket,

      i was running out of time so i bit the bullet and called Microsoft. I'm pretty good at googling and searching forums for answers and i just wasn't getting anything. I've considered moving to Apache a few times but right now i've got a two year old production server that is already overpowered and has much room for expansion running IIS so i cannot justify the conversion...yet.

      I have to hand it to the tech at MS. He had it figured out in about 20 minutes and then helped me come up with a php script that will assist in testing.

      The problem was that the client's HTTP POST was ultimately calling the directory and not the script. His machine was sending the line:

      POST test/processor HTTP/1.1<CR><LF>

      Where test/processor is a directory on the server and my script was index.php in that directory. It turns out that my client needed to append a trailing slash to his POST command so that IIS would return the default document.

      Yikes! It all comes full circle. i don't use Apache much but i used to years ago and remember having trouble with trailing slashes in my http.conf. I've never heard of such a thing from IIS.

      Anyway, thank you for your assistance. More questions to come regarding this project but at least i've got incoming data now!

      thanks again,
      dean

        Write a Reply...