Hi,
I have a simple rest web service which is running in the Tomcat. I tested my web service successfully using REST Client for FireFox.
Now, I used PHP socket to post xml as string to my web service. But I got HTTP/1.1 405 Method Not Allowed error.
I used the following code:
I would be glad, if someone kindly help me to figure out this problem.
Thank you.
I have a simple rest web service which is running in the Tomcat. I tested my web service successfully using REST Client for FireFox.
Now, I used PHP socket to post xml as string to my web service. But I got HTTP/1.1 405 Method Not Allowed error.
I used the following code:
Code:
<?php
$str="<?xml version=\"1.0\"?><userEntity><address1>1300 Montecito Avenue</address1></userEntity>";
$d="";
$fp = fsockopen("localhost", 8080, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
fputs($fp, "POST /restWS/users/ HTTP/1.1\r\n");
fputs($fp, "Host: localhost\r\n");
fputs($fp, "Content-type: text/plain\r\n");
fputs($fp, "Content-length: ".strlen($str)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $str."\r\n\r\n");
while(!feof($fp)){
$d .= fgets($fp);
}
fclose($fp);
echo $d;
}
?>
Thank you.