当 HTTP 状态为 202 时,Axis 1.4 不解码 SOAP 信封 - 错误还是功能?

发布于 2025-01-07 14:50:21 字数 1184 浏览 1 评论 0原文

我正在使用 Axis 1.4 连接到 Web 服务。该服务通过使用包含错误描述和 HTTP 状态代码 202 的 SOAP 信封进行响应来发出错误信号。响应如下所示:

<soap:Envelope>
<soap:Body>
 <TestResponse>
  <TestResult>wrong format</TestResult>
 </TestResponse>
</soap:Body>
</soap:Envelope>

测试响应在 WSDL 中进行了描述:

  <s:element name="TestResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="TestResult" type="s:string"/>
      </s:sequence>
    </s:complexType>
  </s:element>

因此,在我看来一切正常。问题是,我没有收到 Axis 生成的存根的错误消息,而是收到 null 。在调试时,我在 HTTPSender 类第 705 行中找到了这一行:

if ((returnCode > 199) && (returnCode < 300)) {
    if (returnCode == 202) {
        return inp;
    }
    // SOAP return is OK - so fall through
} 

它跳过了解码 SOAP 信封的代码。所以,最后,我发送了错误的请求(它可以是运行时的任何内容,例如用户密码过期),我收到错误描述,但因为我使用 Axis,所以我无权访问它并且只收到 null,这使得调试非常困难(我发布的响应是使用 Wireshark 发现的)。

我的问题是,这是错误还是功能?制作 Web 服务滥用 HTTP 状态 202 或标准的公司是否允许这样做,而 Axis 太原始而无法支持它?充其量我想避免使用 apache 或类似的东西手动编码通信。

I'm connecting to web service using Axis 1.4. This service signals error by responding with SOAP envelope with error description and HTTP status code 202. The response looks like that:

<soap:Envelope>
<soap:Body>
 <TestResponse>
  <TestResult>wrong format</TestResult>
 </TestResponse>
</soap:Body>
</soap:Envelope>

The test response is described in WSDL:

  <s:element name="TestResponse">
    <s:complexType>
      <s:sequence>
        <s:element minOccurs="0" maxOccurs="1" name="TestResult" type="s:string"/>
      </s:sequence>
    </s:complexType>
  </s:element>

So, in my opinion everything is OK. The problem is, I don't get that error message with Axis generated stub, receiving null instead. As I debugged, I've found the line in HTTPSender class line 705:

if ((returnCode > 199) && (returnCode < 300)) {
    if (returnCode == 202) {
        return inp;
    }
    // SOAP return is OK - so fall through
} 

It skips the code, that decodes SOAP envelope. So, finally, I've sent wrong request (it can be anything runtime, such as user password expired), I receive error description, but because I use Axis, I have no access to it and receive only null, which makes debugging very hard (the response I posted I've found using Wireshark).

My question is, is it bug or feature? Is the company that have made web service misusing HTTP status 202 or standard allows it and Axis is too primitive to support it? At best I would like to avoid coding communication manually using HttpClient from apache or anything similar....

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

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

发布评论

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

评论(1

陌伤ぢ 2025-01-14 14:50:21

这看起来像一个错误。 HTTP 202 Accepted 状态代码用于指示请求已被接受,但需要进一步处理才能完成。响应应该有一个Location标头,表示可以对服务进行的回调,以检查请求状态,以及一个可选的正文描述性消息。

对于 Web 服务,我希望服务实现者能够处理主体响应,只要其内容与服务契约(在本例中为 WSDL)相匹配。但 Axis 的实施者可能有不同的感受。

无论如何,供应商错误地使用 202 状态代码来返回错误,这是问题的一个(大)部分。

That looks like a bug. The HTTP 202 Accepted status code is used to indicate that a request has been accepted, but further processing is required in order to complete it. The response should have a Location header representing a callback that can be made to the service, to check the request status, and an optional body with a descriptive message.

For a web service, I would expect that service implementors process the body response as long as its content matched the service contract (in this case the WSDL). But the implementors of Axis might have felt differently.

In any case, the vendor is incorrectly using 202 status codes to return errors, and that is a (big) part of the problem.

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