The Web reference VS2003 for a WCF service contains Extra & ldquo; IdSpecified & rdquo; Parameter


I am developing a WCF service using VSTS 2008 + .Net 3.5 + C# and it works fine when I also use VSTS 2008 to develop client (using Add Service Reference function to automatically generated client web services proxy code). The WCF I developed is using basicHttpBinding.

The issue I met with is, when I use Visual Studio.Net (Visual Studio 2003) to generate client web services proxy code, there is an additional input parameter for a OperationContract method called IdSpecified (bool type). I have tested that when specify IdSpecified to true, the value of Id parameter will be passed to WCF server side correctly, but when I specify IdSpecified to false, no matter what values I specify to Id parameter, at WCF server side, Id will be always 0. I also tried for input parameter type like string, there is no such additional input parameter at client side.

My question is why there is an additional parameter? What is its meaning and is it possible to avoid generate such additional parameter?

Here is Visual Studio.Net automatically generated client side web services proxy code,

public StudentInfo Poll(int Id, [System.Xml.Serialization.XmlIgnoreAttribute()] bool IdSpecified)

Here is my VSTS 2008 WCF server side code,

StudentInfo Poll(int Id);

EDIT 1: here is part of the automatically generated code at client side about Poll method.

[return: System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public StudentInfo Poll(int Id, [System.Xml.Serialization.XmlIgnoreAttribute()] bool IdSpecified) {
    object[] results = this.Invoke("Poll", new object[] {
    return ((StudentInfo)(results[0]));


This behavior is by design, and has been there since .NET 1.0. In fact, if you were to create an ASMX web service with VS2003, with the same method signature, you would find the same result.

The issue is with value types that are marked in the WSDL as not being required. Since they are value types, they can't return null (and VS2003 did not have nullable types). The solution that Microsoft implemented was to add a separate boolean field or property you can set to say whether or not you are supplying the value.

This means that when your .NET 1.1 application wants to call the service, it needs to set the IdSpecified parameter:

using (WebReference1.PollService svc = new WebReference1.PollService()) {
    StudentInfo info = svc.Poll(id, true); // True to specify

I haven't tried this, but why don't you:

public class PollParameters {
    [DataMember(Required = true)]
    public int Id;

public StudentInfo Poll(PollParameters parameters);

Try that and see what the proxy looks like in VS2003.