My .Net Wrapper Class Fails when accessed with a Web Service

D

Dave Capper

Hi,

I've got a problem with a class that I have written to wrap up access to an
API. Basically, the wrapper instantiates an old COM API, and then executes
its login method, which has a system DSN as a parameter. This wrapper works
fine when I use it in a Windows application, i.e. the login method works
correctly resulting in the API being logged into the database.

When I try to put a webservice front-end onto this class the login method
fails.

I am guessing that the problem comes from the web service accessing the DSN,
but it is only a guess. Is there any way around this? Is it a security
setting that prevents the DSN being accessed?

Please help!

Cheers,
Dave

P.S. In the code below, bLoggedIn returns true for the Windows application,
but false for the Web Service.

Here is the basics of the code:

WRAPPER CLASS

Public Class HEATWrapper
Private hwsIT As haWorkspace 'This will be the single reference to HEAT
Private Const sUserName As String = "xxxx"
Private Const sPassword As String = "xxxx"
Private Const sDSN As String = "MHD_DSN"

Public Sub New()
End Sub

Private Function GetConnection() As haWorkspace
Dim bLoggedIn As Boolean = False

'Login to HEAT Application
If hwsIT Is Nothing Then
hwsIT = New haWorkspace
End If
If Not hwsIT.LoggedIn Then
bLoggedIn = hwsIT.Login(sUserName, sPassword, sDSN)
End If
If bLoggedIn Then
Return hwsIT
Else
Return Nothing
End If
End Function

Public Function GetCustomerID(ByVal strCustomerType As String, ByVal
strEmail As String, ByVal strCustName As String) As String
Dim objHEAT As haWorkspace

Try
objHEAT = GetHEATConnection()
...
Catch ex As Exception
Throw ex
End Try
End Function

<Various other functions to expose the API methods>
End Class

WINDOWS APPLICATION:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim hwHEAT As New HEATWrapper

Try
MessageBox.Show(hwHEAT.GetCustomerID("Customer", "",
"CustomerName"))
Catch ex As Exception
Throw ex
End Try
End Sub

WEB METHOD
<WebMethod()> Public Function GetCustomerID(ByVal strCustName As String)
As String
Dim hwHEAT As New HEATWrapper

Try
Return hwHEAT.GetCustomerID("Customer", "", strCustName)
Catch ex As Exception
Throw ex
End Try
End Function
 

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

Forum statistics

Threads
473,771
Messages
2,569,587
Members
45,099
Latest member
AmbrosePri
Top