Simon Fell > Its just code > .NET headers remix edition

Wednesday, November 8, 2006

In his post Trade-Offs, Sam points to my post last year on trying to have SOAP headers with simple types in .NET. In the comments Asbjørn Ulsberg claims that the behavior is related to handling nulls, and that its fixed in .NET 2.0. Well, lets see shall we.

To start with, the header defined is not nillable, therefore that's a complete read herring. as a reminder, here's the element definition that's detailed in the post and in the WSDL.

<s:element name="ValidFrom" type="s:dateTime"/>

I fired up .NET 2.0's WSDL.exe tool and pointed it at the first wsdl (you can play along at home if you want to)

Microsoft (R) Web Services Description Language Utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'C:\sampleCode\dotnet20_headers\TestService.cs'.
And lets take a look at the generated code
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Xml.Serialization.XmlRootAttribute("ValidFrom", Namespace="", IsNullable=false)]
public partial class dateTime : System.Web.Services.Protocols.SoapHeader {
    private string[] textField;
    public string[] Text {
        get {
            return this.textField;
        set {
            this.textField = value;
Looks remarkably like the .NET 1.1 version (except for the fields vs properties thing), so, no, not fixed, not any better.