简体   繁体   中英

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? By default, BasicHttpBinding requires the SOAPAction.

I need this to provide compatibility with a client that does not use SOAPActions. This is my SOAP message:

<?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. Thanks!

It's not an issue of BasicHttpBinding, it's an issue of adhering to the SOAP 1.1 standard which says:

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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