Adding a public property to a web service

Results 1 to 2 of 2

Thread: Adding a public property to a web service

  1. #1
    Join Date
    Dec 1969

    Default Adding a public property to a web service

    Hello all,<BR><BR>I&#039;m building a web service that will process HTML formatted newsletters for approximately 1500 recipients. I would like to use a couple of properties in this service. I&#039;ve created a web method and have added a public property to the class. The problem is when I add a web reference to my aspx project, the web methods are exposed, but the public property is not. My code is structured like the following:<BR><BR>Imports System.Web.Services<BR><BR>&#060;WebService(Namesp ace := "")&#062; Public Class Service1<BR> Inherits System.Web.Services.WebService<BR> Public strHelloWorld As String = ""<BR><BR> &#060;WebMethod()&#062; Public Function HelloWorld() As String<BR> HelloWorld = setString<BR> End Function<BR><BR> Public Property setString() As String<BR> Get<BR> If strHelloWorld = "" Then<BR> setString = "Hello World"<BR> Else<BR> setString = strHelloWorld<BR> End If<BR> End Get<BR> Set(ByVal Value As String)<BR> setString = Value<BR> End Set<BR> End Property<BR><BR>End Class<BR><BR>Do I have to expose the property using something like the "&#060;WebMethod()&#062;" tag?<BR><BR>Thanks in advance,<BR><BR>Russ

  2. #2
    Join Date
    Dec 1969

    Default RE: Adding a public property to a web service

    Giving an object a property implies that it is stateful - web services are by definition stateless, so the concept of a property is meaningless. You can emulate it by maintaining session state behind the scenes, but its messy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts