tags:

views:

127

answers:

1

I'm working on some legacy code, and I need an asmx to implement a particular wsdl, which is being provided to me.

I would like to receive the root element of the message as either an XmlDocument or XmlNode, rather than the wsdl.exe generated object graph. Is this even possible?

A: 

First of all, you should use svcutil.exe, not wsdl.exe, unless you have no other choices.

Second, you don't need either program to implement an external WSDL. Just go write your service so that the XML Serializer will properly serialize and deserialize the incoming message. In particular, if you like processing XML, try this:

[WebMethod]
public XmlElement SomeOperation(XmlElement parameter)
{
}

I believe that the same works with the newer XElement class.

In WCF (which is what you should be using, since Microsoft now considers ASMX web services to be "legacy technology"), I believe you should use the Message type:

[OperationContract]
Message SomeOperation(Message parameter);
John Saunders
Thanks. It turns out that the XmlElement parameter has to have the same name as the root ele of the payload element. It's a tactical change to legacy code, swapping in WCF or switching to XmlSerialization would take too long unfortunately. (I suggested both!)
James L