views:

180

answers:

4

This is very odd, and I'm just wondering if anyone can explain this to me. I have a web service run by traditional old asmx style web services. We had a public property that was used in a internal method that was not displayed to consumers like this:

public class User {
   public string EmployeeID;

   protected override void DoSomething(){
      var foo = EmployeeId;
   }
}

now here is the weird part. We decided the get rid of this field. But because Apache Axis clients are tied to a particular wsdl, we did not want to remove it from the wsdl. So we left the property but removed its usages in the internal methods. When we did this the property suddenly went missing from the WSDL...but ONLY on servers running IIS6. Developers running IIS 5.1 still get the property.

We ended up putting a trivial usage back into the methods (getting and setting it into a empty string.) and suddenly it showed up again on IIS6 servers.

Whats up with that?

+2  A: 

Sounds a little bit similar to this problem I had.

A property wasnt in the wsdl as it had a private setter.

Paul Rowland
Possibly, In my case everyone was public, however, the class was written long long ago under .net 1.something and so did not have the {get; set;} declarations. I think it may be related to your problem. If it is, you may get the bounty yet!
ryber
A: 

The "public string EmployeeID;" is not property declaration but field declaration. Are you sure, the class from wsdl is generated, has a property not a field?

TcKs
the field is listed as <s:element minOccurs="0" maxOccurs="1" name="EHRIEmployeeID" type="s:string" /> when as a public field
ryber
A: 

Are the servers it disappeared from have .NET 3.5 installed by chance while the servers which still show it NOT have that version? Not sure if this question might be the same thing you're encountering or if you've marked the field/property as [Obsolete], which .NET (2.0 and above) does not serialize.

Jesse C. Slicer
A: 

My guess is that you are seeing one of the lovely side effects of compiler optimization:

  • You've got a field-level declaration that is never used.
  • The compiler sees this in one of its many passes and says "Hey, nobody's using this"
  • The compiler removes the declaration, content that this tiny optimization will harm no one.
  • Later on, when the WSDL is generated, the assembly is reflected against, now missing that nice public variable nobody was using.

Now in theory, this should only happen on "release builds", but I don't know enough about the various optimizations the compiler is "authorized" to do to give a definitive answer.

JerKimball