Phantom Properties

Yet one more interesting Web Service problem reared its head today.  The situation is as follows:

The result of a call to a Web Service method is supposed to be a class. The class contains the elements that, basically, make up a record in a database table.  Because of the way that we structure data access, our data access class returns a DataSet with a matching xsd file.  Once the xsd file had been created, the xsd.exe tool was used to create the class definition.  An instance of the class was then hydrated using the XML format of the DataSet and returned through the web service.

(just for the curious amongst you, our reason for not returning the DataSet itself is that the client is an older version of WebSphere and they don't have easy support for processing returning DataSets.)

Key point coming:  the minOccurs value on at least some of the data elements in the xsd was set to 0.  As a result, for some of the data types (specifically integers, int16 and bytes), additional properties were created.  For example, if there were a property called Status, a public boolean property called StatusSpecified would also be created. 

No problem to this point.  A web method is created with a return value of the class that was generated by xsd.  The method is called and *bam* (picture Emeril at this point), an error gets generated.  The error is the following:

Server was unable to process request. File or assembly name q2k5rmkd.dll, or one of its dependencies, was not found.

The experienced among you will recognize this as a error that occurs when the ASP.NET user doesn't have access to the temporary directory.  But that was not the case here. It is also an error that gets returned when one of the classes used in a web service message has a ReadOnly property.  But a review of the returned class shows that this is not the case either. 

As it turns out, the problem is that the Specified properties (such as StatusSpecified) conflicts with an automatically generated property called, coincidentally, StatusSpecified.  This automatic property is generated when the result set contains a minOccurs clause.  It is used with numeric values to identify those properties that have not been assigned.  It is necessary because numeric variables don't have a 'null' value. But the conflict between the autogen'ed properties and the properties that are created by xsd causes the error message seen above.  The easiest solution is to change the name of the properties included in the xsd.exe generated class to have a name that does not have 'Specified' as the suffix.

Comments

  • bruce May 13, 2004 12:26 PM

    You mention that this error can happen for more common reasons, such as no access to the temporary directory. What temp directory do you mean?

    We deployed some web services on a workgroup server and were having no problems accessing them from workstations in other domains and workgroups. Then, we promoted the web services machine to a domain server. At that point, we got this error. Any ideas?

  • bruce June 24, 2004 9:39 AM

    It would be the Windows Temp folder, as we just found out when a customer complained that our product had stopped working (after a dns-change, they claimed).

  • bruce October 4, 2004 8:45 AM

    I love you Bruce Johnson's SOA(P) Box.
    Have been trying to crack this bug for many hours now =).
    Thanx!

  • bruce February 26, 2005 9:09 AM

    We had changed the application pool to run as a specific user (because of a DNS change), and received this error. By giving that user full permissions to the TEMP direcotry it works great now. Thanks a lot!

  • bruce August 24, 2006 8:10 AM

    Regarding the autogenerated Specified properties. Is there somhow to override this autogeneration?

  • Aditya Sen January 31, 2008 10:57 AM

    You're a life saver. I faced exactly the problem you described, using classes generated from an xsd using the .net xsd tool. Thanks a ton. God bless you!

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS