如何强制 Axis2 使用 HTTP 1.0 进行 Web 服务调用?

发布于 2024-12-29 17:22:50 字数 446 浏览 5 评论 0原文

我在访问第三方提供的网络服务时遇到问题。查看 Axis2 线迹,我可以在返回的 XML 标记中间看到 \r\n3ff8\r\n,这导致 Axis2 在尝试解析它们时发出嘶嘶声。

据我所知,这与 Axis2 处理不好的 HTTP 1.1 分块有关。

我遇到的问题与 此论坛帖子

如何更改我的 Web 服务代码以使其使用 HTTP 1.0 以避免分块问题?据我所知,Axis 默认为 CommonsHTTPSender,所以我不确定为什么上面链接的论坛帖子建议更改为该设置。

或者有更好的方法来解决这个问题吗?

I'm having issues accessing a web service provided by a third party. Looking at the Axis2 wire trace I can see \r\n3ff8\r\n in the middle of my the XML tags coming back which is causing Axis2 to have a hissy fit when it tries to parse them.

As far as I can tell this has something to do with HTTP 1.1 chunking which Axis2 isn't handling very well.

The issue I'm having is Identical to the issue in this forum post

How can I change the my webservice code to make it use HTTP 1.0 to avoid the chunking issue? As far as I can tell Axis defaults to CommonsHTTPSender anyway so I'm unsure why the forum post linked above suggested changing to that.

Alternatively is there a better way to solve this problem?

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

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

发布评论

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

评论(2

时光倒影 2025-01-05 17:22:50

您可以直接关闭分块:

stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);

如果您愿意,您还可以通过 axis2.xml 配置文件来控制这两个功能。找到以下部分:

<transportSender name="http"
    class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
    <parameter name="PROTOCOL">HTTP/1.1</parameter>
    <parameter name="Transfer-Encoding">chunked</parameter>
</transportSender>

您可以将 PROTOCOL 参数更改为“HTTP/1.0”,或删除 Transfer-Encoding 参数以禁用分块。

You can directly turn off chunking:

stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, false);

You can also control both of these things through the axis2.xml config file, if you'd prefer. Find the following section:

<transportSender name="http"
    class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
    <parameter name="PROTOCOL">HTTP/1.1</parameter>
    <parameter name="Transfer-Encoding">chunked</parameter>
</transportSender>

You can change the PROTOCOL parameter to "HTTP/1.0", or remove the Transfer-Encoding parameter to disable chunking.

⊕婉儿 2025-01-05 17:22:50

了解如何执行此操作,获取将用于调用服务的存根对象,并在其后添加以下代码:

stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
                org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);

Found out how to do it, get the stub object that you you will use to call the service and add the following code after it:

stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
                org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文