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

发布于 2024-12-31 22:05:18 字数 6173 浏览 0 评论 0原文

我通过 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>

I call a web service via Apache Axis Client in Tomcat server. I get ISO-8859-1 encoded response xml instead of UTF-8. When i simply run this client form main method, everything works as excepted. Below is an example request and response xml log. Please help!

In Message:

<?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>

Out Message:

<?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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福还没到 2025-01-07 22:05:18

你可以尝试下面的代码。

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

you can try following codes.

Stub._setProperty(Call.CHARACTER_SET_ENCODING, "ISO-8859-9");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文