简体   繁体   中英

Public property missing from WSDL served by IIS 6

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?

Sounds a little bit similar to this problem I had .

A property wasn't in the wsdl as it had a private setter.

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM