PRB: Read-Only Properties Cannot Be Exposed by XML Web Services (313584)
The information in this article applies to:
- Microsoft Web Services (included with the .NET Framework 1.1)
- Microsoft Web Services (included with the .NET Framework) 1.0
This article was previously published under Q313584 SYMPTOMSNote The following .NET Framework Class Library namespaces are
referenced in this article:
System.Web.Services
If a Web
service contains a Web method that either accepts a parameter or returns a
value that is an object reference, and the class definition of the object
contains a read-only property, the read-only property is not available when you
build a proxy assembly for the Web service.
Note The following .NET Framework Class Library namespace is
referenced in this article:
SystemCAUSE When an object is passed (that is, marshalled) to or from a
Web service, it must be serialized into an XML stream and then deserialized
back into an object. The XML Serializer cannot deserialize the XML back into an
object because it cannot load the read-only properties. Consequently, the
read-only properties are not exposed through the Web Services Description
Language (WSDL). Because the Web service proxy is generated from the WSDL, the
proxy also excludes any read-only properties. RESOLUTION To work around this problem, add a SET procedure for the
property. You can either leave the procedure empty, so that that the procedure
has no effect, or raise a custom exception to inform clients that the property
is read-only, as follows:
Public Property Id() As Integer
Get
Return nID
End Get
Set(ByVal Value As Integer)
Throw New Exception("Cannot set read-only property 'Id'")
End Set
End Property
STATUSThis
behavior is by design.REFERENCES301273 HOW TO: Write a Simple Web Service by Using Visual Basic .NET
| Modification Type: | Major | Last Reviewed: | 9/26/2003 |
|---|
| Keywords: | kbprb kbWebServices KB313584 |
|---|
|