Hi Oleg,
Thanks for response, I put log in the code, It seems from httpclient, I
send whole string in right character set encoding, but when I retireve it
from server side, it's messed up, do you have any idea?
Here's the code of client.
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT,
"http");
String userId ="userid";
String password="password";
String URL =
"/test/testServlet?"+USERID+EQUAL+userId+"&"+PASSWORD+EQUAL+password;
PostMethod authpost = new PostMethod(URL);
try {
FileInputStream fis = new FileInputStream(XMLFilename);
int x = fis.available();
byte b[] = new byte[x];
fis.read(b);
String content =new String(b);
System.out.println("Login form post: " + new
Integer(content.length()));
RequestEntity entity = new
StringRequestEntity(content,"text/plain","UTF-8");
//RequestEntity entity = new FileRequestEntity(input,
"text/xml; charset=ISO-8859-1");
authpost.setRequestEntity(entity);
client.executeMethod(authpost);
System.out.println("Login form post: " +
authpost.getResponseBodyAsString());
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and here's servlet code.
String dealWithPayload(HttpServletRequest req)
{
byte[] buf = null;
try
{
System.out.println("retireve length =
........................"+ new Integer(req.getContentLength()));
buf = new byte[req.getContentLength()];
req.getInputStream().read(buf);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return new String(buf);
}
After I receive xml string from server side, I printed it out, the end of
string looks like:
<wsibf7:vacationPay>
<wsibf7:noVacationPay>Y</wsibf7:noVacationPay>
</wsibf7:
............................................................................................................................
>From log, I can get everything right. As log is too big, I just send you
part of it. It includes whole string of xml and looks fine.
2007/08/15 08:49:26:338 EDT [DEBUG] content - >> "<?xml version="1.0"
encoding="UTF-8"?>[\r][\n]"
2007/08/15 08:49:26:338 EDT [DEBUG] content - >> "<wsibf7:Form7>
..........................................
2007/08/15 08:49:26:568 EDT [DEBUG] content - >> "</wsibf7:Form7>[\r][\n]"
2007/08/15 08:49:26:568 EDT [DEBUG] EntityEnclosingMethod - Request body
sent
Thanks again.
Jacky
*********************************************************************
The information in this e-mail is intended solely for the addressee(s)
named, and is confidential. Any other distribution, disclosure or
copying is strictly prohibited. If you have received this communication
in error, please reply by e-mail to the sender and delete or destroy all
copies of this message.
Les renseignements contenus dans le pr'esent message 'electronique sont
confidentiels et concernent exclusivement le(s) destinataire(s)
'esign'e(s). Il est strictement interdit de distribuer ou de copier ce
message. Si vous avez recu ce message par erreur, veuillez r'epondre
par courriel `a l'exp'editeur et effacer ou d'etruire toutes les copies du
pr'esent message..