Hi,
I am trying to send an xml String using HTTP Post method. The connection goes well and i receive HTTP_OK as response, but dont know why its not executing the php script where I am sending the data.
Presently I am testing by creating an empty text file on the server side when I hit the page with the POST data.
Here is the code for the two
PHP Code
<?
if($_POST !=NULL){
$file = fopen("text.txt","w+");
}
else{
echo "M here";
}
?>
Here is the code for the connection....
PHP Code:
String response;
HttpConnection conn = null;
DataInputStream in = null;
DataOutputStream out = null;
try {
conn = (HttpConnection) Connector
.open("URL",Connector.READ_WRITE);
conn.setRequestMethod(HttpConnection.POST);
out = conn.openDataOutputStream();
out.write("barankhan".getBytes());
out.flush();
out.close();
Dialog.alert("rest"+conn.getResponseCode()+HttpConnection.HTTP_BAD_REQUEST);
in = conn.openDataInputStream();
bytexxx91;xxx93; data = new bytexxx91;200xxx93;;
int numBytes = in.read(data);
StringBuffer responseBuffer = new StringBuffer();
in.close();
conn.close();
for (int i = 0; i < numBytes; i++) {
responseBuffer.append((char) dataxxx91;ixxx93;);
}
response = responseBuffer.toString();
Dialog.alert(response);
} catch (IOException e) {
System.out.println("Here is exception" + e.getMessage());
}
Hope to hear something great!!!