• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connecting to IIS server using midlet --Error in HTTP operation.

 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am trying to connect to IIS server and trying to get an ASPX page.
But I always get the error Error in HTTP operation.
I tried a similar code(I had set the user agent) for getting a JSP page on Tomcat,but that seems to work fine.

I have pasted my code below.It always throws an IO exception at c.flush()

Any suggestion would be greatlt appreciated.


HttpConnection c = (HttpConnection) Connector.open("http://localhost:2021/test.aspx");
String rawData = "orders="+"none"+"&cust="+"cus1"+"&mob="+"none";

String type = "application/x-www-form-urlencoded";
c.setRequestMethod(HttpConnection.POST);

c.setRequestProperty( "Content-Type", type );
c.setRequestProperty("Content-Language","en-US");
c.setRequestProperty( "Content-Length", Integer.toString(rawData.length()));

OutputStream os = c.openOutputStream();
os.write( rawData.getBytes() );
os.flush();

if ((i=c.getResponseCode()) == HttpConnection.HTTP_OK)
{

sb = new StringBuffer();
int ch;

is = http.openInputStream();
while ((ch = is.read()) != -1)
sb.append((char) ch);

reply=sb.toString();
}

c.close();




Cheers,
Sam
 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is my code faulty?.Does anyone have any suggestions
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic