×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    6

    https in MIDP2.0

    I have the following PC java code that works:

    URL ulr0 = new URL ("...");
    HttpsURLConnection con0 = (HttpsURLConnection)
    url0.openConnection();
    con0.setRequestMethod( "POST" );
    con0.setUseCaches( false );
    con0.setDoInput( true );
    con0.setDoOutput( true );
    con0.addRequestProperty ( "Cookie",
    "BrowserTest=Success?;version=1" );
    OutputStream out0 = con0.getOutputStream();
    String toOut = "login=" + userid + "&" + ...
    out0.write( toOut.getBytes() );
    out0.flush();
    String ret = getContent( con0.getInputStream(),
    con0.getContentLength() );
    con0.disconnect();

    This is my MIDP translation:

    String url0 = new String("...");
    HttpsConnection c = null;
    InputStream is = null;
    OutputStream os = null;
    c = (HttpsConnection)Connector.open(url0);
    c.setRequestMethod( HttpsConnection.POST );
    c.setRequestProperty
    ( "Cookie", "BrowserTest=Success?;version=1" );

    os = c.openOutputStream();
    String toOut = "login=" + userid + "&" + ...;
    os.write( toOut.getBytes() );
    os.flush();

    int rc;
    rc = c.getResponseCode();
    if (rc != HttpConnection.HTTP_OK)
    {
    os.close();
    c.close();
    throw new Exception("Cannot send message to passport
    server");
    }
    is = c.openInputStream();
    StringBuffer sb = new StringBuffer();
    sb.setLength(0);
    int ch;
    while ((ch = is.read()) != -1)
    {
    sb.append((char)ch);
    }
    is.close();
    os.close();
    c.close();
    String ret = new String(sb);

    It does not work: the getResponseCode() function returns code 500 (internal server error). What's wrong with my code?

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    Netherlands
    Posts
    18
    Start by looking at the server log to see what the error is if that's possible. That should give you some hint at what is happening...

    Regards,

    Jac

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    6
    I cannot get data from the server as it is the MSN server (I'm trying to build an MSN client for MIDP2.0 phones)

    Bye

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Then set up a dummy server that is accesible to you, change the MIDlet so that it connects to your server, solve the problem, then change it back.

    shmoove

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    14

    Re: https in MIDP2.0

    Im having a similar issue...
    The problem is the responseCode is whatever is setted in the declaration...
    IE
    int responseCode = 0;
    responseCode = mHttpConnection.getResponseCode();

    the return is always 0.
    Any ideas

  6. #6
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: https in MIDP2.0

    Have you checked the server logs as suggested above?

    Hartti

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •