我在WCF服务上遇到了消息解析问题。
我运行了WCF应用程序的服务器端。另一家公司向我发送了这样的HTTP POST请求:
POST /telemetry/telemetryWebService HTTP/1.1
Host: 192.168.0.160:12123
Content-Length: 15870
Expect: 100-continue
Connection: Keep-Alive
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security> ... </wsse:Security>
</soapenv:Header>
<soapenv:Body>
...
</soapenv:Body>
</soapenv:Envelope>
在这个HTTP请求中,缺少两个重要的标头:Soap Action和Content-type。这就是为什么我的服务无法正确处理此请求的原因。
我需要捕获请求直到开始处理并手动添加这些标头。
我已经尝试过IDispatchMessageInspector,但没有任何结果。
IDispatchMessageInspector
没有成功,可以展示一下相关代码和出现的问题/错误吗?请注意,您随时可以编辑您的问题。(另外,我不确定在客户端解决这个问题是否可行?) - Jeroen