PRB: Read-Only and Write-Only Class Properties Not Accessible from a Web Service (317270)
The information in this article applies to:
- Microsoft Visual Studio .NET (2003), Professional Edition
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft .NET Framework 1.1
- Microsoft Visual Studio .NET (2002), Professional Edition
- Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2002), Academic Edition
- Microsoft .NET Framework 1.0
This article was previously published under Q317270 SYMPTOMS When you try to access read-only and write-only properties
of a class that you obtain from a Web service, you cannot view the properties.
CAUSE XML serialization and ASP.NET Web services do not support
read-only and write-only properties. Information about these properties is not
published in Web Services Description Language (WSDL) documentation.
WORKAROUND To access the properties, use the Web methods in the WebService class. To do this, follow these steps:
- In the Service1.asmx.vb file, paste the following Web
methods after the #Region " Web Services Designer Generated Code" block:
<WebMethod()> Public Function GetValue1() As Integer
Dim c1 As New Class1()
GetValue1 = c1.Value1
End Function
<WebMethod()> Public Function SetValue2(ByVal x As Integer) As Boolean
Dim c2 As New Class1()
c2.Value2 = x
Return True
End Function
- In
the WebForm1.aspx.vb
file, instead
of code that tries to directly access the properties, paste
the following code in the
Page_Load
method:
data="Dim i as Integer
i = myVar2.GetValue1
myVar2.SetValue2(5)"?>Dim myvar As New localhost.Service1
Dim myInt As Int32
myInt = myvar.GetValue1
myvar.SetValue2(100)
STATUSThis
behavior is by design.
Modification Type: | Major | Last Reviewed: | 2/11/2004 |
---|
Keywords: | kbprb KB317270 kbAudDeveloper |
---|
|