您的位置:首页 > 运维架构 > Tomcat

Weblogic: Exceeded stated content-length

2012-03-29 18:27 429 查看
URL url = new URL("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl");
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("Content-Length", Integer.toString(soap.length()));
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
conn.setRequestProperty("SOAPAction", http://WebXml.com.cn/getWeatherbyCityName);

 

在tomcat下好使,但是在WebLogic下就挂了,报错

 

java.net.ProtocolException: Exceeding stated content length of 358


怎么会超长呢?

 

原因:

content-length这个是所传报文的byte类型的长度,而并非string字符串的长度,tomcat的编码格式iso-8859-1 ,而weblogic是GBK(或UTF-8)

这样就导致了超长。

 

解决办法:

conn.setRequestProperty("Content-Length", String.valueOf(soap.getBytes().length))就OK了!

  

转自:http://hite.iteye.com/blog/681903
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  weblogic tomcat url string byte
相关文章推荐