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

Discussion in 'ASP .Net Web Services' started by Dave Capper, Sep 10, 2003.

  1. Dave Capper

    Dave Capper Guest

    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
    Dave Capper, Sep 10, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shelly Adhikari
    Replies:
    3
    Views:
    349
    red floyd
    Sep 10, 2003
  2. Replies:
    2
    Views:
    1,229
    jacob navia
    Sep 14, 2006
  3. Bangalore
    Replies:
    3
    Views:
    400
    werasm
    Jun 23, 2006
  4. James

    Help! Web service can't be accessed!

    James, Mar 1, 2005, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    205
    Dan Rogers
    Mar 7, 2005
  5. David05

    Web Service Wrapper/Proxy/Redirect

    David05, Sep 10, 2008, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    429
    David05
    Sep 10, 2008
Loading...

Share This Page