I encountered a strange bug in how ASP.NET generates sample SOAP request/responses in .NET 1.1 (this may be the case on 1.0 as well - haven't tested). Take a look at this very simple web service, that includes a header:
using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Serialization; namespace TestHeaderWS { public class MyHeaderType : SoapHeader { public System.Xml.XmlElement AnyThing; } public class TestHeaderService : System.Web.Services.WebService { [WebMethod] [SoapHeader("MyHeader")] [return: XmlElementAttribute(Namespace="")] public string DoSomething() {return null;} public MyHeaderType MyHeader; } }
Now point your browser to http://localhost/TestHeaderWS/TestHeaderService.asmx, select the DoSomething operation, and take a look at the sample SOAP request displayed. You should see something like this:
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <MyHeaderType xmlns="http://tempuri.org/"> <AnyThing> <DoSomethingResult xmlns=""> <string>string</string> <string>string</string> </DoSomethingResult> <string xmlns="">string</string> </AnyThing> </MyHeaderType> </soap:Header> <soap:Body> <DoSomething xmlns="http://tempuri.org/" /> </soap:Body> </soap:Envelope>
Notice how messed up the sample response is - for some reason, it is embedding what actually is the result XML (DoSomethingResult) in the header. There are two triggers to cause this bug (fyi, the service appears to actually work properly, so this isn't a big deal).
Page rendered at Monday, October 06, 2008 1:02:05 PM (Pacific Daylight Time, UTC-07:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.