This post regards the last hurdle in completing my task of communicating with a Cisco router via the Web Services Management Agent (WSMA), as described here and here. You will not have to read those posts to understand my current question, though.

The problem is this: I have build service and message contracts to match the router's web services, and configured a basicHttpBinding and an endpoint. And using a channel factory, I am now almost, but not quite, communicating successfully with the router.

I keep getting a SOAP fault in return, stating that "An expected XML tag or sequence is missing". Using WCF tracing, fiddler and debugging on the router, and manually posting messages over HTTP, I have finally figured out what's going on.

The WSMA agent on the router expects the SOAP message payload in the HTTP request to include an XML declaration. And WCF isn't sending one. As simple as that.

So my question is: How can I make WCF, using a basicHttpBinding, include an XML declaration in the message?

I've followed all your threads regarding Cisco WSMA and .NET. Could you provide a full sample somewhere? I'm running into the same issues and would like to automate this.
–
makerofthings7Mar 28 '11 at 18:03

1 Answer
1

You will have to create custom encoder. Check WCF samples. Provided sample shows how to create new encoder with composition of existing one. You will use TextMessageEncodingBindingElement to create inner MessageEncoder. Your WriteMessage implementatoin will write XML declaration and than call inner encoder to write serialized message.

You will also need to wrap your new encoder in custom binding element and use it in custom binding together with HttpTransportBindingElement.

Yup. More work than I'd hoped for, but it seems the only way. And it worked very well. Thanks.
–
Tor HaugenSep 20 '10 at 0:06

@TorHaugen I know you've done this work on wsma long time back. But now i'm trying to work on it, still it lacks docs. Can you tell me how the Notify mode works? Some ref should be nice.
–
AntarusJun 6 '13 at 11:47

@Ladislav Mrnka I've the same problem with my WCF client. Your solution seems a bit complex, can we instead intercept the message and add the xml declaration?
–
daniel.tekleSep 9 '13 at 23:24