hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ramit bhardwaj" <ram...@cybage.com>
Subject RE: query as byte array
Date Wed, 01 Mar 2006 13:35:43 GMT
If you want to send the byte array in the post body use the following code

Suppose the xmlString you want to send is in xmlString variable.
byte[] byteArrData = xmlString.getBytes("UTF-8"); 
			ByteArrayInputStream bis = null;
//Suppose your byte array is ->byteArrData then set that data in the
constructor
			bis = new ByteArrayInputStream(byteArrData);
//suppose your Post object is post then set this byte array input stream to
the request body.
post.setRequestBody(bis); 



Hope this helps





-----Original Message-----
From: Chaitanya Ravi [mailto:r.chaitanya@gmail.com] 
Sent: Wednesday, March 01, 2006 6:47 PM
To: HttpClient User Discussion
Subject: Re: query as byte array

Hey thankyou..

On 3/1/06, Oleg Kalnichevski <olegk@apache.org> wrote:
>
> On Wed, 2006-03-01 at 18:03 +0530, Chaitanya Ravi wrote:
> > Simple:
> >
> > I want to send ü (Utf-8) characters to server side.
> >
> > my query string is something like this:
> >
> > <%3Fxml%20version%3D"1.0"%20encoding%3D"UTF-8"%20standalone%3D"no"%3
> > F>
> >
> <soap%3AEnvelope%20xmlns%3Asoap%3D"http%3A%2F%2Fschemas.xmlsoap.org%2F
> soap%2Fencoding%2F"">
> > <soap%3ABody>
> > <isponsorrequest%20credentials%3D"Axi5dm1fnQMi%3D"%20version%3D"2.0"
> > >
> >
> > ....
> >  <select>
> > <where>
> > <name=üg%3Astaff"%2F>
> > <%2Fwhere>
> > <%2Fselect>
> >
> > ....
> > <%2Fisponsorrequest>
> > <%2Fsoap%3ABody>
> > <%2Fsoap%3AEnvelope>
> >
> > Everything is working well except when in send such utf-8 characters.
> > At the server i see ü as ?
> >
> > I hope am clear
> >
> >
>
> OK, one more time: sending XML messages as a query string makes _no_ 
> sense, because request URI is not simply intended for passing large 
> entities _especially_ if they use non-ASCII characters. Per URI spec 
> only ASCII characters are permissible.
>
> When using HTT POST make sure you apply the _same_ charset encoding
> (UTF-8 in this case) on both ends of the HTTP transport. You can see 
> what gets sent across the wire by activating the wire logging on the 
> client side
>
> Hope this helps
>
> Oleg
>
> >
> >
> >
> >
> > On 3/1/06, Oleg Kalnichevski <olegk@apache.org> wrote:
> > >
> > > On Wed, 2006-03-01 at 17:42 +0530, Chaitanya Ravi wrote:
> > > > Even the post doesn't work. Its the same way.
> > > >
> > >
> > > What specifically does not work?
> > >
> > >
> > > > The only way to help sending unicode characters is to send it as 
> > > > bytearray.Am not finding any method to do it :(
> > > >
> > > > Can the developers add something like 
> > > > methodBase.setQueryStrin(byte[])
> ?
> > > >
> > >
> > > What for? Just URL encode query strings that contain non ASCII 
> > > characters if you insist on sending the request body in the query 
> > > string.
> > >
> > >
> > > > Meanwhile can someone suggest workaround ?
> > > >
> > >
> > > What you are trying to do makes no sense. Just use POST.
> > >
> > > Oleg
> > >
> > > >
> > > >
> > > > On 3/1/06, Oleg Kalnichevski <olegk@apache.org> wrote:
> > > > >
> > > > > On Wed, 2006-03-01 at 15:11 +0530, Chaitanya Ravi wrote:
> > > > > > Hi
> > > > > >
> > > > > > I wan tot send the query as the byte array since my query 
> > > > > > string
> > > > > includes
> > > > > > unicode characters. How can i do this ?
> > > > > >
> > > > > > GetMethod method = new GetMethod("/Sponsor"); 
> > > > > > method.setQueryString(" I send xml string here");
> > > > > >
> > > > > > But if i have unicode characters in the xmlstring, they 
> > > > > > don't
> get
> > > sent
> > > > > > properly. So, i want to convert the xml string into byte 
> > > > > > array
> and
> > > send
> > > > > it
> > > > > > to my server.
> > > > > >
> > > > > > Please help
> > > > >
> > > > > Why not just use POST?
> > > > >
> > > > > Oleg
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail:
> httpclient-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail:
> > > httpclient-user-help@jakarta.apache.org
> > > > >
> > > > >
> > >
> > >
> > > ------------------------------------------------------------------
> > > --- To unsubscribe, e-mail: 
> > > httpclient-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> httpclient-user-help@jakarta.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> httpclient-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message