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

  • Thread starter Tino Donderwinkel
  • Start date
T

Tino Donderwinkel

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>
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top