Passing Parameters into NEW()

B

Bubba Thomas

Is there any way that the NEW() of a web service can accept parameters ? I
would like to pass a boolean to indicate to the webservice that I am in test
mode or live mode. This will give me the ability to set up which Database I
want to use on the back end. If I cannot do it this way does anyone know of
another way I can do it ? I have a WebService that has about 75 procedures
and I would rather not have to submit this parameter into every one of them.

I would like to do something like this :


Private agentMonitorConnectionStringLive As String =
"uid=callManager;pwd=liveon070703;" &
"database=callManager;server=129.110.10.235;Connect Timeout=45"
Private agentMonitorConnectionStringTest As String =
"uid=callManager;pwd=callManager;" &
"database=callManager;server=129.110.205.11;pooling='false';Connect
Timeout=45"
Private queueMessagesConnectionLive As String =
"uid=FrontOffice;pwd=liveon070703;" &
"database=FrontOffice;server=129.110.10.235;Connect Timeout=45"
Private queueMessagesConnectionTest As String =
"uid=FrontOffice;pwd=FrontOffice;" &
"database=FrontOffice;server=129.110.205.11;Connect Timeout=45"
Public agentMonitorConnectionString As String
Public queueMessagesConnectionString As String

Public Sub New(ByVal LiveMode As Boolean)

If LiveMode Then
agentMonitorConnectionString = agentMonitorConnectionStringLive
queueMessagesConnectionString = queueMessagesConnectionLive
Else
agentMonitorConnectionString = agentMonitorConnectionStringTest
queueMessagesConnectionString = queueMessagesConnectionTest
End If

End Sub



TIA !


Bubba !
 
M

Michael Pearson

Well, you could setup two different webservices. In your client side code,
determine if you are in debug mode and call one or the other.

How does that sound?

Michael
 
M

Matthew Holton

May I suggest an additional header, pass one in if you
are in debug mode, and not if you are not.

Class OptionalHeader : Inherits SoapHeader
Public DebugMode as boolean
End Class
 
B

Bubba Thomas

This would be my LAST resort as there are many, many objects that have to
have access to the webservice.


I appreciate the help anyway !


Bubba !
 
B

Bubba Thomas

I am not familiar with this idea.... Could you give me an example (or point
me to one) ?

I would really appreciate it !


ThanX

Bubba !
 
M

Matthew Holton

Certainly

Imports System.Web.Services
Imports System.Web.Services.Protocols

' Define a SOAP header by deriving from the SoapHeader
base class.
Public Class StartUpParamaters : Inherits SoapHeader
Public IsDegug As Boolean
Public Sub New()
'
'
'
End Sub
End Class


<WebService(Namespace:="http://myserver.mydomain.com/")>
Public Class Manager
Inherits System.Web.Services.WebService

Public oHead as StartUpParamaters

<WebMethod(EnableSession:=True), SoapHeader
("oHead",Direction := SoapHeaderDirection.In, _
Required := False))> Public Function Login(ByVal
UserName As String, ByVal Password As String) As Integer

if oHead.IsDebug then
'Write to trace log
end if
End Function
End Class

'Client

Public Shared Sub Main()
Dim ws As New Manager()

Try
Dim customHeader As New StartUpParamaters()

customHeader.IsDebug = True

ws.myHeader = customHeader

Dim results As Integer

results = ws.Login("UserName","Password")
Catch e As Exception
Console.WriteLine("Exception: {0}", e.ToString
())
End Try
End Sub

ms-
help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWebServices
ProtocolsSoapHeaderClassMustUnderstandTopic.htm

ms-
help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWebServices
ProtocolsSoapHeaderAttributeClassDirectionTopic.htm

ms-
help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfSystemWebServices
ProtocolsSoapHeaderAttributeClassRequiredTopic.htm


HTH

Matthew
 
B

Bubba Thomas

I presume that I need to place the following at each one of my functions and
procedures ?

<WebMethod(EnableSession:=True), SoapHeader("oHead",Direction :=
SoapHeaderDirection.In, _
Required := False))> PUBLIC FUNCTION () OR PROCEDURE()

ThanX again for the help !

Bubba !
 
G

Guest

You are correct.
-----Original Message-----
I presume that I need to place the following at each one of my functions and
procedures ?

<WebMethod(EnableSession:=True), SoapHeader ("oHead",Direction :=
SoapHeaderDirection.In, _
Required := False))> PUBLIC FUNCTION () OR PROCEDURE()

ThanX again for the help !

Bubba !






.
 

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,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top