web-services - Tomcat 上的 Apache Axis 字符集编码错误?

标签 web-services tomcat encoding utf-8 axis

我通过 Tomcat 服务器中的 Apache Axis 客户端调用 Web 服务。我得到 ISO-8859-1 编码的响应 xml 而不是 UTF-8。当我简单地运行此客户端表单主要方法时,一切正常。下面是一个示例请求和响应 xml 日志。请帮忙!

在消息中:

<?xml version="1.0" encoding="UTF-8"?>
<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>
        <ns1:getContactInformation
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xmlns:ns1="http://extranet.turkcell.com.tr/webServices/toskaWebService">
            <longVal href="#id0" />
            <longVal0 href="#id1" />
            <longVal1 href="#id2" />
            <longVal2 href="#id3" />
            <integer href="#id4" />
            <integer0 href="#id5" />
            <integer1 href="#id6" />
            <integer2 href="#id7" />
        </ns1:getContactInformation>
        <multiRef id="id1" soapenc:root="0"
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">-1</multiRef>
        <multiRef id="id6" soapenc:root="0"
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">408</multiRef>
        <multiRef id="id0" soapenc:root="0"
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">-1</multiRef>
        <multiRef id="id2" soapenc:root="0"
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">5322067832</multiRef>
        <multiRef id="id3" soapenc:root="0"
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xsi:type="xsd:long" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">-1</multiRef>
        <multiRef id="id5" soapenc:root="0"
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">100</multiRef>
        <multiRef id="id7" soapenc:root="0"
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0</multiRef>
        <multiRef id="id4" soapenc:root="0"
            soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
            xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">1</multiRef>
    </soapenv:Body>
</soapenv:Envelope>

外出留言:

<?xml version="1.0" encoding="ISO-8859-9" standalone="yes"?>
<env:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <env:Header></env:Header>
    <env:Body env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <m:getContactInformationResponse
            xmlns:m="http://extranet.turkcell.com.tr/webServices/toskaWebService">
            <result xmlns:n1="java:com.turkcell.toska.model" xsi:type="n1:WSContactList">
                <addresslist soapenc:arrayType="n1:WSAddress[1]">
                    <WSAddress xsi:type="n1:WSAddress">
                        <address1 xsi:type="xsd:string">7-8 Mah. I 9 C Kap�s�</address1>
                        <address2 xsi:type="xsd:string">�orak�� Sok. No:111</address2>
                        <address3 xsi:type="xsd:string">Gazzosmanpa�a</address3>
                        <addressID xsi:type="xsd:long">0</addressID>
                        <addressStatus xsi:type="xsd:int">0</addressStatus>
                        <addresstype xsi:type="xsd:int">0</addresstype>
                        <addressusage xsi:type="xsd:int">1</addressusage>
                        <cityCode xsi:type="xsd:int">72</cityCode>
                        <cityName xsi:nil="true"></cityName>
                        <countryCode xsi:type="xsd:int">1</countryCode>
                        <usageStatus xsi:type="xsd:int">0</usageStatus>
                        <zipCode xsi:type="xsd:string">72439</zipCode>
                    </WSAddress>
                </addresslist>
                <emaillist soapenc:arrayType="n1:WSEmailInfo[0]"></emaillist>
                <errMessage xsi:type="xsd:string"></errMessage>
                <phonelist soapenc:arrayType="n1:WSPhone[1]">
                    <WSPhone xsi:type="n1:WSPhone">
                        <addressID xsi:type="xsd:long">0</addressID>
                        <addressStatus xsi:type="xsd:int">0</addressStatus>
                        <extension xsi:nil="true"></extension>
                        <generationDate xsi:nil="true"></generationDate>
                        <modificationDate xsi:nil="true"></modificationDate>
                        <phonenumber xsi:type="xsd:string">2125487549</phonenumber>
                        <phonenumbertype xsi:type="xsd:int">100</phonenumbertype>
                        <usageStatus xsi:type="xsd:int">0</usageStatus>
                    </WSPhone>
                </phonelist>
                <resultcode xsi:type="xsd:int">0</resultcode>
            </result>
        </m:getContactInformationResponse>
    </env:Body>
</env:Envelope>

最佳答案

您可以尝试以下代码。

Stub._setProperty(Call.CHARACTER_SET_ENCODING, "ISO-8859-9");

关于web-services - Tomcat 上的 Apache Axis 字符集编码错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9093078/

相关文章:

java - 如何关闭jetty调试?

tomcat - 如何使用浏览器在 Windows 7 中启动 apache tomcat 服务?

python - 如何在 Python 中创建 GSM-7 编码?

php - 用于提取 Microsoft Onenote 文档信息的库/服务

java - Spring Rest 模板 - 来自 Web 服务的 204 内容响应

java - 什么版本的 apache tomcat 支持 netbeans 中的 java 7 功能?

unicode - 为什么字符é在UTF-8中编码为0xC3 0xA9?

c# - Facebook json 消息的编码/解码问题。 C#解析

c# - 我已经创建了一个 WCF 服务,现在我想从引用中调用它,但为什么会出现 InvalidOperationException?

java - Tomcat - Eclipse 中的服务器