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