commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sanjeev Tripathi" <sanjeev.tripa...@parago.com>
Subject Http Client- How to send and recieve Serialized Object using Http Client
Date Mon, 07 Feb 2005 19:17:58 GMT
Hi,

 

I am working on thick client proxy that will connect to servlet and
retrive and save data to database. I am using Http Client for
communication.

 

 I am able to send string values using parameter in request as follows. 

 

//**********************************************************************
****

        NameValuePair userid   = new NameValuePair("LOGIN_NAME",
"login");

        NameValuePair password = new NameValuePair("LOGIN_PASSWORD",
"password");

        NameValuePair thickClient = new NameValuePair("ThickClient",
"ThickClient");

 

        authpost.setRequestBody(

          new NameValuePair[] {action, url, userid,
password,thickClient});

 

//**********************************************************************
****

 

I am able to send xml string as parameter and able to receive it back
from response as String.

 

 But I am getting problem in serialized user defined objects
communication. Following is not working

 

 

 

//*************************In Servlet*****************

 

if (request.getParameter("ThickClient").equals("ThickClient"))  {

 

 

   response.setContentType("application/octel-stream");

   ObjectOutputStream oos = new
ObjectOutputStream(response.getOutputStream());

   oos.writeObject(new com.parago.communication.SubmissionVO(1,"Controll
Servlet"));

 

   oos.flush();

   oos.close();

   return;

}

 

 

 

 

******************** In Thick Client Proxy *************************

 

 

 

        client.executeMethod(authpost);      

 

        System.out.println("Login form post: " +
authpost.getStatusCode());

         ObjectInputStream ois = new
ObjectInputStream(authpost.getResponseBodyAsStream());

        SubmissionVO vo = (SubmissionVO)ois.readObject();

        System.out.println("id :" +vo.getSubmissionId() +": desc:" +
vo.getDescription());

 

 

 

//******************Here SubmissionVO is Serialized Object***********

 

public class SubmissionVO implements java.io.Serializable{

    public SubmissionVO(int id,String desc) {

        this.submissionId = id;

        this.description = desc;

    }

    private int submissionId;

    private String description;

 

    public int getSubmissionId () {

        return submissionId;

    }

    public String getDescription() {

        return description;

    }

}

//***********************************************************

 

 

 

 

Please suggest me. How to send and receive Serialized User Defined Value
Objects in using Http Client.

 

 

 

Thanks.

 

Sanjeev Tripathi

 

 

 

 

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message