Getting raw XML messages from ASMX

Don has an interesting post on what he found exploring the dark corners of ASMX and WSDL. In particular, his first point is:

In general, you have to use the wsdl:part/@element attribute with doc/lit EXCEPT when using ASMX's “wildcard mode.”  Wildcard mode uses the wsdl:part/@type attribute and places no restriction on the type of the body element(s). In wildcard mode, ASMX won't try to deserialize into a strongly typed object but rather presents the body as one or more XmlElement references.  

This is definitely true when you want the body of the message to be anything. I don't believe that's a very common case, however. It's more likely that you want to consume a message with a known format as raw XML. To do that, you need a signature like this:

[SoapDocumentMethod(ParameterStyle=SoapParamterStyle.Bare,
                    Use=SoapBindingUse.Literal)]
[return: XmlElement(“AddResponse“, “urn:mindreef-com:example“)]
public XmlElement Add(
  [XmlElement(“Add“, “urn:mindreef-com:example“)] XmlElement req) {...}

There are no issues with this approach viz the WS-I Basic Profile. The only issue is that if you generate WSDL from this signature, you'll get messages whose content model is <xs:any/>. This is different from what Don was doing, where the message itself is unknown.

 


Posted Nov 22 2004, 07:15 AM by tim-ewald

Add a Comment

(required)  
(optional)
(required)  
Remember Me?