Hi 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: [email protected]
For additional commands, e-mail: [email protected]