Send https request

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Send https request

Postby acidcromaticle » Tue Oct 05, 2010 1:01 pm

Hello,
I'm trying to make a microsoft communications messenger client for android :D.

Now i'm working at the connection and logon methods, and i have a problem.

I have to send to Communications server a https request with user's username and password and the server will then send back a authenticate response with a uri to use it next to create the session.

The response is in a xml format and i receive the response but with an error :(. I think that i dont send the user and pass corectly through the request, because i had deleted the user and pass and the error is still the same, after that i've tried to run the code without sending the user and pass and i had received the same error.

the error is : <cwaResponses><requestFailed eid="4"/></cwaResponses>

My code is:
Code: Select all
        SchemeRegistry schemeRegistry = new SchemeRegistry();
       
        schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(),
                443));
        params = new BasicHttpParams();
        params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 1);
        params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE,
                new ConnPerRouteBean(1));
        params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, "utf8");

        clientConnectionManager = new ThreadSafeClientConnManager(params,
                schemeRegistry);

         context = new BasicHttpContext();
         context.setAttribute("cwaRequest",
         "<cwaRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org.org/2001/XMLSchema\" xmlns=\"http://schemas.microsoft.com/2006/09/rtc/cwa\"><logon><user>domain\\user</user><password>pass</password></logon></cwaRequest>");

        HttpClient client = new DefaultHttpClient(clientConnectionManager,
                params);

        HttpGet httpget = new HttpGet("https://ocs-srv.domain:4443/mcx/mcxform/logon.html");

         httpget.addHeader("cwaRequest",
         "<cwaRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org.org/2001/XMLSchema\" xmlns=\"http://schemas.microsoft.com/2006/09/rtc/cwa\"><logon><user>domain\\user</user><password>pass</password></logon></cwaRequest>");
        try {

            HttpResponse response = client.execute(httpget);

            String str = EntityUtils.toString(response.getEntity());

            Toast.makeText(Acom.this, "mesaj: " + str, Toast.LENGTH_LONG)
                    .show();

        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            Toast.makeText(Acom.this, "e1: " + e, Toast.LENGTH_LONG).show();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            Toast.makeText(Acom.this, "e2: " + e, Toast.LENGTH_LONG).show();
        }


The big problem is that i dont know how to send the user and pass by the request.
I have searched on google and i'm trying to find how can i make the logon session.

I hope somebody can help me .

Thank you!


EDIT: - now i know what method to use to request the logon infos.. the method is POST, i tried to make the example from this forum with the post request but i get the same error, and the error it tels that i am sending the request in a bad format, i get that error even if i dont put something in the post's entity.

Can anyone help me please? Thank you!
acidcromaticle
Freshman
Freshman
 
Posts: 2
Joined: Mon Oct 04, 2010 8:15 am

Top

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests