Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Routing WCF Calls based on Body Element - How to rout empty element?

53 views
Skip to first unread message

Tino Donderwinkel

unread,
Aug 7, 2010, 4:59:33 AM8/7/10
to
Hi,

I have a simple WCF Services that impelements some standard that uses SOAP
1.1 without WS-Addressing.
Hence, I need to route messages based on the Body element of the message (by
using the IDispatchOperationSelector).
The 'datacontract' was generated by means of XSD.EXE. So I have to use the
XmlSerializerFormatAttribute on the service definition.
Last, the implementation required understanding of some custom SOAP headers.

This all works fine... Except...

There is one specific call defined by the standard that has NO body part. I
need to route these calls as well.
Since the BODY part of the SOAP message is empty, I get an XmlException;
The body of the message cannot be read because it is empty.

Okay, that's perfectly legal; it's in the standard.

Now how can I 'work around' this? Is there a way that I can 'parse' these
messages?
I do have a 'default' Operation Contract set up;
[OperationContract(Action = "*", ReplyAction = "*")]

But the Exception is thrown well before this is hit.

How can I accept, and route, these 'empty' messages?

Here's an example of such a message; (I have skipped the xmlns declarations
for clarity)

<s:Envelope>
<s:Header>
<Action s:mustUnderstand="1"></Action>
<somens:CUSTOMHEADER SOAP-ENV:mustUnderstand="1" xmlns:somens="..."
>100</somens:CUSTOMHEADER>
</s:Header>
<s:Body>Nothing more.</s:Body>
</s:Envelope>

As you can see, the <Action> header is empty because of not using
WS-Addressing.

Here's my Service Contract;

[ServiceContract, DispatchByBodyElementBehavior]
[XmlSerializerFormat(SupportFaults = true, Use = OperationFormatUse.Literal,
Style = OperationFormatStyle.Document)]
public partial interface IMyInterface
{
[OperationContract(ReplyAction = "*"), DispatchBodyElement("DoThis",
"somens")]
DoThisMessageResponse DoThis(DoThisMessage doThisMessage);
[OperationContract(Action = "*", ReplyAction = "*")]
Message DefaultOperation();
}

I also tried this;

[OperationContract(Action = "", ReplyAction = "*")]
Message EmptyOperation();

To no avail...

Any ideas?

Thanks,

Tino

0 new messages