creating a BED properties class with web services

S

steven

hi

i'm working on a web site (written in .net 1.1) that makes heavy use
of web services written in .net 2.0. the web site needs to sniff the
URL being used and set certain parameters like db connections (to the
QA or Production DB based on the URL). these properties should all be
captured in an AppConfig properties class and passed to the web
service. I'd like the AppConfig properties class to be written as a
web service, but there doesn't seem to be any support for things like:

<WebMethod()> _
Public Property DBConn()
Get
Return _dbConn
End Get
Set(ByVal value)
_dbConn = value
End Set
End Property

i guess i could create this properties class with a bunch of functions
to do this:

<WebMethod()>_
Public Function GetDbConn as String
return _dbConn
End Function

<WebMethod()>_
Public Sub SetDbConn(ByVal sDbConn As String)
_dbConn = sDbConn
End Sub

but is there a more elegant way of doing this?

any suggestions appreciated.

tks
 
J

John Saunders [MVP]

steven said:
hi

i'm working on a web site (written in .net 1.1) that makes heavy use
of web services written in .net 2.0. the web site needs to sniff the
URL being used and set certain parameters like db connections (to the
QA or Production DB based on the URL). these properties should all be
captured in an AppConfig properties class and passed to the web
service. I'd like the AppConfig properties class to be written as a
web service, but there doesn't seem to be any support for things like:

<WebMethod()> _
Public Property DBConn()
Get
Return _dbConn
End Get
Set(ByVal value)
_dbConn = value
End Set
End Property

i guess i could create this properties class with a bunch of functions
to do this:

<WebMethod()>_
Public Function GetDbConn as String
return _dbConn
End Function

<WebMethod()>_
Public Sub SetDbConn(ByVal sDbConn As String)
_dbConn = sDbConn
End Sub

but is there a more elegant way of doing this?

any suggestions appreciated.

Sorry, web methods can only be methods.

Furthermore, you should consider something more granular. Keep in mind that
each reference to a web method is a request/response pair. You don't really
want to do 10 separate request/response exchanges just to fetch 10
properties.

Instead, consider wrapping a set of properties in a class, and have a single
web method called, say, "GetConfigurationProperties" that returns the entire
set. The client can then access the individual properties however it likes.
--
 
S

steven

Sorry, web methods can only be methods.

Furthermore, you should consider something more granular. Keep in mind that
each reference to a web method is a request/response pair. You don't really
want to do 10 separate request/response exchanges just to fetch 10
properties.

Instead, consider wrapping a set of properties in a class, and have a single
web method called, say, "GetConfigurationProperties" that returns the entire
set. The client can then access the individual properties however it likes.

tks for the advice, john. my approch was feeling a little forced.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top