如何处理非 SOAP 错误消息?

How to handle a non-SOAP error message?

我有一个 WCF 客户端用于 SAP 系统中的一组服务。对于某些错误,服务(据称)无法 return SOAP 错误。相反,我收到这样的信息:

<?xml version="1.0"?>
<jpr:Fault xmlns:jpr="http://com.sap/aii/proxy/xiruntime/">com.sap.aii.proxy.xiruntime.core.ESPXISystemFaultException: Error encountered during processing of XI request message in inbound ESP; Hint: com.sap.engine.interfaces.webservices.runtime.RuntimeProcessException: Response did not arrive for request 8d4b2782-062a-11e6-b0f9-0000193763e3</jpr:Fault>

以上表示服务中的某种类型的超时。我在这里可用的唯一一条信息将其标识为超时,是这段文字:Response did not arrive for request

有 WSDL,但供应商并没有认真对待它们。我还要求尝试给我一个 SOAP 错误,但他们坚持认为在这种情况下这是不可能的。

我该如何处理这样的消息?目前,我收到这个异常链:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ServiceModel.CommunicationException: Unrecognized message version.

这是可能的,但您将不得不使用一些低级位。您想要到达的位置是在客户端通道中,您可以在该通道中安装您的组件以处理此类响应。查看 WCF Extensibility – Channels,您可以在其中找到如何创建协议通道。

之后你可以创建你的自定义绑定,在你有传输(必须存在)、你的协议、编码器等的地方堆叠通道...