gpt4 book ai didi

java - 从 SOAP 响应中获取 HTTP 状态代码

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:12:03 25 4
gpt4 key购买 nike

如何从 SOAPConnection.call() 的结果中获取 HTTP 状态?

最佳答案

取自W3C note on SOAP (Section 6.2)

SOAP HTTP follows the semantics of the HTTP Status codes for communicating status information in HTTP. For example, a 2xx status code indicates that the client's request including the SOAP component was successfully received, understood, and accepted etc.

In case of a SOAP error while processing the request, the SOAP HTTP server MUST issue an HTTP 500 "Internal Server Error" response and include a SOAP message in the response containing a SOAP Fault element (see section 4.4) indicating the SOAP processing error.

来自documentation on SOAPFault in the API

An element in the SOAPBody object that contains error and/or status information. This information may relate to errors in the SOAPMessage object or to problems that are not related to the content in the message itself.

所以,一个可能的答案是

SoapMessage soapMessage = null;
soapMessage = MySOAPConnection.call(...);
soapMessage.getSOAPPart().getEnvelope().getBody().getFault().getFaultCode();

帮助我创建此答案的一些引用资料是:

关于java - 从 SOAP 响应中获取 HTTP 状态代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15741412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com