Make read-only properties visible to Web Services clients

Read-only and write-only properties in a Web Service class aren’t visible to the Web Service client. The reason is that XML serialization doesn’t support these sort of properties, and read-only and write-only properties aren’t included in the Web Services Description Language (WSDL) documentation.

To make these properties visible to clients, create a Function that returns the value of a read-only property, or a Sub that assigns a write-only property, and decorate them with the WebMethod attribute. For example:

Dim m_Count As Integer ReadOnly Property Count() As Integer   Get      Return m_Count    End GetEnd Property ' This is the method visible to the Web Service's clients Function GetCount() As Integer    Return CountEnd Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: