简体   繁体   English

没有SOAPAction标头的WCF Web服务

[英]WCF web service without SOAPAction header

How can I implement a web service in WCF such that it does not require the SOAPAction header to be present in the request, and would thus dispatch the call using the message body root element name? 如何在WCF中实现Web服务,使得它不需要SOAPAction头部出现在请求中,从而使用消息体根元素名称调度调用? By default, BasicHttpBinding requires the SOAPAction. 默认情况下,BasicHttpBinding需要SOAPAction。

I need this to provide compatibility with a client that does not use SOAPActions. 我需要这个来提供与不使用SOAPActions的客户端的兼容性。 This is my SOAP message: 这是我的SOAP消息:

<?xml version='1.0' encoding='UTF-8'?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<messageDeliveryReport xmlns="http://bogus/ns"><status>D</status><systemName>cc</systemName></messageDeliveryReport>
</env:Body></env:Envelope>

and I want it to call 'messageDeliveryReport' operation. 我想让它调用'messageDeliveryReport'操作。 Thanks! 谢谢!

It's not an issue of BasicHttpBinding, it's an issue of adhering to the SOAP 1.1 standard which says: 这不是BasicHttpBinding的问题,它是遵守SOAP 1.1标准的问题, 该标准说:

An HTTP client MUST use this header field when issuing a SOAP HTTP Request.

So what you're dealing with is a client that doesn't conform to a standard that's existed since 2000. You might be able to work around this problem by implementing one of the extensibility points of WCF which are explained in greater detail in the MSDN article Extending WCF with Custom Behaviors , probably either IDispatchMessageInspector or IDispatchOperationSelector , but the request may not even make it that far since the message really isn't a valid SOAP request to begin with. 所以你所处理的是一个不符合自2000年以来存在的标准的客户端。你可以通过实现WCF的一个扩展点来解决这个问题,这在MSDN中有更详细的解释。 使用自定义行为扩展WCF ,可能是IDispatchMessageInspectorIDispatchOperationSelector ,但请求可能甚至没有那么远,因为消息确实不是一个有效的SOAP请求开始。

您可以按照此示例构建自定义行为,以便根据消息正文的根元素将SOAP消息分派到操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM