I am a programmer but very new to php and web programming.
I will be most grateful for your help!
I have been given vague instructions to:
"submit XML to the server, in a post parameter called xmlData.
Listen on the same connection, and wait for a response.
Once a response comes in, accept the xml response. This does not come in a
parameter, it is just written to the output stream on the original connection."
I believe I have done the request correctly, my problem is that I dont seem to get XML back, I just get an html page.
Here is my code:
$encodedString = urlencode($myString);
$server= 'www.someserver.com';
$url = '/something.jsp';
$content_length = strlen($encodedString);
$headers= "post $url HTTP/1.0\r\nContent-type: text/html\r\nHost: $server\r\nContent-length: $content_length\r\n\r\n";
$connection = fsockopen($server, 80, $errno, $errstr);
if (!$connection) return false;
fwrite($connection, $headers);
fwrite($connection, "xmlData=".$encodedString);
$result = "";
while (!feof($connection))
{
$result.= fread($connection, 1024);
}
fclose($connection);
print $result;
The result is the following html page:
<html>
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=1FBA128B2301735A01680F36709AB497; Path=/vapp
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 32
Date: Tue, 21 Apr 2009 17:45:48 GMT
</body>
</html>
I realise I will need to figure out how to parse the xml response, but I will worry about that later.
I just expect that I will be able to see the xml response as text first?
Am I doing something wrong, or is their response incorrect?
Should I include "https://" in the server name?
Many thanks in advance!!