|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
French accents problem while sending postMethodHi All,
Seems that i have some problem to send parts containing non ascii characters using multi part post request. What i do is : [CODE] FilePartSource fileSource = new FilePartSource(f); Part[] parts = { new StringPart("commandxml", commandxml, "UTF-8"), new FilePart("uploadFile", fileSource) }; // Part[] parts = { new StringPart("commandxml", commandxml, "ISO-8859-1"), // new FilePart("uploadFile", fileSource) }; postMethode.setRequestEntity(new MultipartRequestEntity(parts, postMethode.getParams())); client = new HttpClient(); client.getHostConfiguration().setProxy( BatchBol.propMan.getProperty("proxyHost"), Integer.valueOf(BatchBol.propMan.getProperty("proxyPort"))); client.getHttpConnectionManager().getParams().setConnectionTimeout( 5000); int status = client.executeMethod(postMethode); [/CODE] calling a web service sending multi part post. The first part consist in a xml formated string such as : <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <createdocument> <authentication token="Cnk05awANGBw1epAOnApcPy3RueQCk_evrpBt0UPiLtVEmCKXL-5XSko71coaryt-Lk8O_Yrz9e-BOn7NexdFA"/> <workspace name="WorkspaceName" id="14058"/> <category id="38181"/> <parent id="14836645"/> <attributes> <attribute value="Test ADEX" name="TITLE"/> <attribute value="Mes réf : 12345" name="REFERENCE"/> <attribute value="12345" name="REVISION"/> <attribute value="20/09/2009" name="DUE_DATE"/> </attributes> </createdocument> and the second part is a file. See attached file to have a look at the code. What's happen is that the "Mes réf" thing becomes Mes r[0xc3][0xa9]f and unfortunatly doesn't work with the server side. It seems that when HttpClient create the parts it re-encodes the content (red and bold in the log trace): >> "Content-Type: " 2009-09-22 11:32:38,691 DEBUG [httpclient.wire.content] - >> "text/plain" 2009-09-22 11:32:38,691 DEBUG [httpclient.wire.content] - >> "; charset=" 2009-09-22 11:32:38,691 DEBUG [httpclient.wire.content] - >> "UTF-8" 2009-09-22 11:32:38,691 DEBUG [httpclient.wire.content] - >> "[\r][\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "Content-Transfer-Encoding: " 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "8bit" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "[\r][\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "[\r][\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "<createdocument>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " <authentication token="wHBqUT18Ok0ypUwr8ldqUdzeFw1BuxZUb7gyTaSyzSxFmSJiASEqbTJi5vfQo-lihZ7l8iNWob2rDIqX_XDvkQ"/>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " <workspace name="Veritas SandBox" id="14058"/>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " <category id="38181"/>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " <parent id="14836645"/>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " <attributes>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " <attribute value="Test ADEX" name="TITLE"/>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " <attribute value="*Mes r[0xc3][0xa9]f *: 12345" name="REFERENCE"/>[\n]" 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " <attribute value="12345" name="REVISION"/>[\n]" 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> " <attribute value="20/09/2009" name="DUE_DATE"/>[\n]" 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> " </attributes>[\n]" 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> "</createdocument>[\n]" 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> "[\r][\n]" 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> "--" 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> "qL7OM3nhrkaLANtlVTT5cn1bnsFM9T" 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> "[\r][\n]" Any idea of what to do to correctly handle latin chars? Best regards Nicolas. --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
|
|
|
Re: French accents problem while sending postMethodOn Tue, Sep 22, 2009 at 02:54:44PM +0200, Nicolas Beucler wrote:
> So i suppose, then that it's the other side that doesen't decode > correctly the XML string? > Most likely. Oleg > Regards. > > Nicolas > Oleg Kalnichevski a ??crit : > > On Tue, Sep 22, 2009 at 11:35:32AM +0200, Nicolas Beucler wrote: > > > >> Hi All, > >> > >> Seems that i have some problem to send parts containing non ascii > >> characters using multi part post request. > >> > >> What i do is : > >> [CODE] > >> FilePartSource fileSource = new FilePartSource(f); > >> Part[] parts = { new StringPart("commandxml", commandxml, > >> "UTF-8"), > >> new FilePart("uploadFile", fileSource) }; > >> // Part[] parts = { new StringPart("commandxml", commandxml, > >> "ISO-8859-1"), > >> // new FilePart("uploadFile", fileSource) }; > >> postMethode.setRequestEntity(new MultipartRequestEntity(parts, > >> postMethode.getParams())); > >> client = new HttpClient(); > >> client.getHostConfiguration().setProxy( > >> BatchBol.propMan.getProperty("proxyHost"), > >> > >> Integer.valueOf(BatchBol.propMan.getProperty("proxyPort"))); > >> > >> client.getHttpConnectionManager().getParams().setConnectionTimeout( > >> 5000); > >> int status = client.executeMethod(postMethode); > >> [/CODE] > >> calling a web service sending multi part post. > >> > >> The first part consist in a xml formated string such as : > >> > >> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> > >> <createdocument> > >> <authentication > >> token="Cnk05awANGBw1epAOnApcPy3RueQCk_evrpBt0UPiLtVEmCKXL-5XSko71coaryt-Lk8O_Yrz9e-BOn7NexdFA"/> > >> <workspace name="WorkspaceName" id="14058"/> > >> <category id="38181"/> > >> <parent id="14836645"/> > >> <attributes> > >> <attribute value="Test ADEX" name="TITLE"/> > >> <attribute value="Mes r?f : 12345" name="REFERENCE"/> > >> <attribute value="12345" name="REVISION"/> > >> <attribute value="20/09/2009" name="DUE_DATE"/> > >> </attributes> > >> </createdocument> > >> > >> and the second part is a file. > >> > >> See attached file to have a look at the code. > >> > >> What's happen is that the "Mes r?f" thing becomes Mes r[0xc3][0xa9]f and > >> unfortunatly doesn't work with the server side. > >> > >> > > > > This is a perfectly valid UTF-8 representation of this character. > > > > --- > > String s = "???"; > > byte[] raw = s.getBytes(Charset.forName("UTF-8")); > > for (int i = 0; i < raw.length; i++) { > > System.out.print("0x" + Integer.toHexString((raw[i] & 0xFF)) + " "); > > } > > --- > > > >> 0xc3 0xa9 > >> > > --- > > > > Oleg > > > > > > > > > >> It seems that when HttpClient create the parts it re-encodes the content > >> (red and bold in the log trace): > >> > >> > >>>> "Content-Type: " > >>>> > >> 2009-09-22 11:32:38,691 DEBUG [httpclient.wire.content] - >> "text/plain" > >> 2009-09-22 11:32:38,691 DEBUG [httpclient.wire.content] - >> "; charset=" > >> 2009-09-22 11:32:38,691 DEBUG [httpclient.wire.content] - >> "UTF-8" > >> 2009-09-22 11:32:38,691 DEBUG [httpclient.wire.content] - >> "[\r][\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> > >> "Content-Transfer-Encoding: " > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "8bit" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "[\r][\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "[\r][\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> "<?xml > >> version="1.0" encoding="UTF-8" standalone="yes"?>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> > >> "<createdocument>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " > >> <authentication > >> token="wHBqUT18Ok0ypUwr8ldqUdzeFw1BuxZUb7gyTaSyzSxFmSJiASEqbTJi5vfQo-lihZ7l8iNWob2rDIqX_XDvkQ"/>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " > >> <workspace name="Veritas SandBox" id="14058"/>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " > >> <category id="38181"/>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " > >> <parent id="14836645"/>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " > >> <attributes>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " > >> <attribute value="Test ADEX" name="TITLE"/>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " > >> <attribute value="*Mes r[0xc3][0xa9]f *: 12345" name="REFERENCE"/>[\n]" > >> 2009-09-22 11:32:38,707 DEBUG [httpclient.wire.content] - >> " > >> <attribute value="12345" name="REVISION"/>[\n]" > >> 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> " > >> <attribute value="20/09/2009" name="DUE_DATE"/>[\n]" > >> 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> " > >> </attributes>[\n]" > >> 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> > >> "</createdocument>[\n]" > >> 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> "[\r][\n]" > >> 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> "--" > >> 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> > >> "qL7OM3nhrkaLANtlVTT5cn1bnsFM9T" > >> 2009-09-22 11:32:38,722 DEBUG [httpclient.wire.content] - >> "[\r][\n]" > >> > >> Any idea of what to do to correctly handle latin chars? > >> > >> Best regards > >> > >> Nicolas. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: httpclient-users-unsubscribe@... > >> For additional commands, e-mail: httpclient-users-help@... > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > > For additional commands, e-mail: httpclient-users-help@... > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: French accents problem while sending postMethodHi Nicolas,
On Sep 22, 2009, at 2:35am, Nicolas Beucler wrote: > Hi All, > > Seems that i have some problem to send parts containing non ascii > characters using multi part post request. > > What i do is : > [CODE] > FilePartSource fileSource = new FilePartSource(f); > Part[] parts = { new StringPart("commandxml", commandxml, > "UTF-8"), > new FilePart("uploadFile", fileSource) }; > // Part[] parts = { new StringPart("commandxml", > commandxml, > "ISO-8859-1"), > // new FilePart("uploadFile", fileSource) }; > postMethode.setRequestEntity(new > MultipartRequestEntity(parts, > postMethode.getParams())); > client = new HttpClient(); > client.getHostConfiguration().setProxy( > BatchBol.propMan.getProperty("proxyHost"), > > Integer.valueOf(BatchBol.propMan.getProperty("proxyPort"))); > > client.getHttpConnectionManager().getParams().setConnectionTimeout( > 5000); > int status = client.executeMethod(postMethode); > [/CODE] > calling a web service sending multi part post. > > The first part consist in a xml formated string such as : > > <?xml version="1.0" encoding="UTF-8" standalone="yes"?> > <createdocument> > <authentication > token > ="Cnk05awANGBw1epAOnApcPy3RueQCk_evrpBt0UPiLtVEmCKXL-5XSko71coaryt- > Lk8O_Yrz9e-BOn7NexdFA"/> > <workspace name="WorkspaceName" id="14058"/> > <category id="38181"/> > <parent id="14836645"/> > <attributes> > <attribute value="Test ADEX" name="TITLE"/> > <attribute value="Mes réf : 12345" name="REFERENCE"/> > <attribute value="12345" name="REVISION"/> > <attribute value="20/09/2009" name="DUE_DATE"/> > </attributes> > </createdocument> > > and the second part is a file. > > See attached file to have a look at the code. > > What's happen is that the "Mes réf" thing becomes Mes r[0xc3][0xa9]f > and > unfortunatly doesn't work with the server side. > > It seems that when HttpClient create the parts it re-encodes the > content > (red and bold in the log trace): [0xc3][0xa9] are the UTF-8 bytes required to represent é. I'm guessing the log output auto-displays non-7-bit-ascii text using hex codes, to avoid issues with terminals set to us-ascii. Often problems like this are caused by server configuration - e.g. there are countless posts on the Solr mailing list about needing to configure Tomcat to treat incoming URLs as UTF-8. -- Ken -------------------------- Ken Krugler TransPac Software, Inc. <http://www.transpac.com> +1 530-210-6378 --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
|
|
|
Re: French accents problem while sending postMethodOn Tue, Sep 22, 2009 at 06:46:22AM -0700, Ken Krugler wrote:
> OK, either Oleg gets up even earlier than me, or he's not on west coast > time :) > No, I am not :) I guess henceforth I will be answering HttpClient related questions only if they have been unanswered for a couple of days to encourage more participation from the community. Oleg > -- Ken > > On Sep 22, 2009, at 5:50am, Oleg Kalnichevski wrote: > >>> What's happen is that the "Mes r?f" thing becomes Mes r[0xc3][0xa9]f >>> and >>> unfortunatly doesn't work with the server side. >>> >> >> This is a perfectly valid UTF-8 representation of this character. >> >> --- >> String s = "?"; >> byte[] raw = s.getBytes(Charset.forName("UTF-8")); >> for (int i = 0; i < raw.length; i++) { >> System.out.print("0x" + Integer.toHexString((raw[i] & 0xFF)) + " >> "); >> } >> --- >>> 0xc3 0xa9 >> --- >> >> Oleg > > > -------------------------- > Ken Krugler > TransPac Software, Inc. > <http://www.transpac.com> > +1 530-210-6378 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: French accents problem while sending postMethodHi Oleg,
On Sep 22, 2009, at 7:07am, Oleg Kalnichevski wrote: > On Tue, Sep 22, 2009 at 06:46:22AM -0700, Ken Krugler wrote: >> OK, either Oleg gets up even earlier than me, or he's not on west >> coast >> time :) >> > > No, I am not :) I guess henceforth I will be answering HttpClient > related > questions only if they have been unanswered for a couple of days to > encourage > more participation from the community. That was definitely not the intended outcome of my email. Especially since if the question covers anything other than charset issues, the odds of my replying (at least with a useful answer) is slim to none. -- Ken >> On Sep 22, 2009, at 5:50am, Oleg Kalnichevski wrote: >> >>>> What's happen is that the "Mes r?f" thing becomes Mes r[0xc3] >>>> [0xa9]f >>>> and >>>> unfortunatly doesn't work with the server side. >>>> >>> >>> This is a perfectly valid UTF-8 representation of this character. >>> >>> --- >>> String s = "?"; >>> byte[] raw = s.getBytes(Charset.forName("UTF-8")); >>> for (int i = 0; i < raw.length; i++) { >>> System.out.print("0x" + Integer.toHexString((raw[i] & 0xFF)) + " >>> "); >>> } >>> --- >>>> 0xc3 0xa9 >>> --- >>> >>> Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: French accents problem while sending postMethodKen Krugler wrote:
> Hi Oleg, > > On Sep 22, 2009, at 7:07am, Oleg Kalnichevski wrote: > >> On Tue, Sep 22, 2009 at 06:46:22AM -0700, Ken Krugler wrote: >>> OK, either Oleg gets up even earlier than me, or he's not on west coast >>> time :) >>> >> >> No, I am not :) I guess henceforth I will be answering HttpClient related >> questions only if they have been unanswered for a couple of days to >> encourage >> more participation from the community. > > That was definitely not the intended outcome of my email. > > Especially since if the question covers anything other than charset > issues, the odds of my replying (at least with a useful answer) is slim > to none. > > -- Ken > Ken, You have been doing great so far, really. One cannot know all the intricacies of a fairly complex body of code. So, it is not a problem if some answers may be off a little. I most definitely want step away a little and spend less time answering questions on the user list. Therefore I would LOVE to see more HttpClient users helping other users. Cheers Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |