java SOAP中文乱码!!!!

duqiangcise duqiangcise 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我创建soap信息的方式如下:
SOAPMessage soapMessage = messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope requestEnvelope = soapPart.getEnvelope();
SOAPBody body = requestEnvelope.getBody();
SOAPBodyElement tt = body.addBodyElement(requestEnvelope.createName("MTReq"));
SOAPElement subject = tt.addChildElement("Subject");
subject.addTextNode("中文人");

然后我把该soap消息输出到控制台(输出的方式是:soapMessage.writeTo(System.out);),得到的结果是:
------=_Part_0_25292190.1264686044609
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <5A40EDD971F1137EA00571F53DC56662>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>
<MTReq>
<Subject>中文人</Subject>
</MTReq>
</soapenv:Body>
</soapenv:Envelope>
为什么“中国人”的汉字变成了红色部分的乱码呀??
请问大家有什么办法解决这样的乱码吗?????
有什么样的办法改变上面mime头(Content-Type: text/xml; charset=UTF-8)的编码方式为“GB2312”吗??
...全文
评论 4
收藏 已收藏
分享
返回顶部
duqiangcise
Java 51,407 成员 86,137 内容