java SOAP中文乱码!!!!
我创建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”吗??