aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes Serialization using Apache's HttpClient Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Serialization using Apache Watch "Serialization using Apache New topic
Author

Serialization using Apache's HttpClient

Arnab Sahoo
Greenhorn

Joined: Aug 12, 2009
Posts: 3
Hi
Is it not possible to send and receive serialized data using Apache's HttpClient API? I can't find a way to get or send a stream.

Thanks
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6601
    
    1

Please define serialized data. Are you talking about a stream of data ?

Please also change your name to reflect our naming standards

http://www.javaranch.com/name.jsp


SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56529
    
  14

"Angel Eyes", please check your private messages for an important administrative matter.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
You can send and receive stream using HttpClient.

PostMethod postMethod = new PostMethod(url);
postMethod.setRequestBody("your stream goes here");;


SCJP 1.5(97%) My Blog
Arnab Sahoo
Greenhorn

Joined: Aug 12, 2009
Posts: 3
Ok here's the full story.
I want to serialize my objects and send them over to a server and get it's serialized data as well. But I keep getting an SSLHandshake exception.
Now my final problem is to get rid of this.
But, before I do this I have been told to not use URLConnection class (which is what I use right now). Apparently Java's own network classes aren't good (I have personally not seen any result to corroborate this).
So as step 1 I am trying to replace my code using URLConnection with HTTPClient, but for the life of me I can't find out how to serialize and deserialize the data.

Once I do this then I'll try to get rid of the SSLHandshake exception (I have no idea how to do this either).

Is URLConnection really as bad as people say? Or is that a myth?
Arnab Sahoo
Greenhorn

Joined: Aug 12, 2009
Posts: 3
@shivendra tripathi -- PostMethod's setRequestBody seems to take an array of NameValuePairs. NameValuePair seems to comprise only of strings. So how can I pass or send streams ?
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6601
    
    1

Use RMI or EJB or Spring if you want to access serialized objects / make remote calls.

But I keep getting an SSLHandshake exception.


You are using a secure line to transfer the objects and the SSL layer is rejecting the handshake for some reason. The certificate might have expired or the common name is incorrect or something similar
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Serialization using Apache's HttpClient
 
Similar Threads
sending http/php requests from Java applet.
Problem HTTPSURLConnection for Siteminder authentictaion
ServletInputStream
Communicate with the server without a browser.
uploading files with java