Error when consuming a web service

Discussion in 'ASP .Net Web Services' started by Nab, Sep 7, 2008.

  1. Nab

    Nab Guest

    Using a Windows client to consume a web service throws this error:

    System.Web.Services.Protocols.SoapException: Server was unable to process
    request. ---> System.NullReferenceException.....etc

    I'm using Visual Studio 2008 and my VB code for the WS (which is connected
    to a SQL Server 2005 Express) is:

    <WebMethod()> _
    Public Sub GetFee(ByVal brokerName As String, ByRef brokerFee As Single)

    Dim strSQL As String
    strSQL = "SELECT @Fee = dbo_OnlineBrokers.TransactionFee FROM
    dbo_OnlineBrokers WHERE dbo_OnlineBrokers.Name = @BName"
    Dim cmd As New SqlCommand(strSQL, sqlConn)
    cmd.Parameters.Add("@BName", SqlDbType.VarChar, 50)
    cmd.Parameters("@BName").Direction = ParameterDirection.Input
    cmd.Parameters("@BName").Value = brokerName
    cmd.Parameters.Add("@Fee", SqlDbType.Real)
    cmd.Parameters("@Fee").Direction = ParameterDirection.Output
    If cmd.Connection.State <> ConnectionState.Open Then
    cmd.Connection.Open()
    End If
    cmd.ExecuteNonQuery()
    brokerFee = cmd.Parameters("@Fee").Value
    cmd.Connection.Close()

    Any hint as to how to resolve this issue? Is this a permission issue? If so,
    how can I resolve it? Thanks for any suggestions.
     
    Nab, Sep 7, 2008
    #1
    1. Advertising

  2. Did you look up any of these exceptions in the MSDN Library to see what they
    mean? Do that, then get back to us here.

    --
    John Saunders | MVP - Connected System Developer
     
    John Saunders, Sep 7, 2008
    #2
    1. Advertising

  3. Nab

    Nab Guest

    I have fixed this problem. Sending an empty output paramter (argument) to a
    called procedure generated that error. The problem was fixed when I turned
    the procedure into a fucntion that receives just one argument. This problem
    thought did not arise when I used VB2005!! I don't know why.
    --
    UK


    "John Saunders" wrote:

    > Did you look up any of these exceptions in the MSDN Library to see what they
    > mean? Do that, then get back to us here.
    >
    > --
    > John Saunders | MVP - Connected System Developer
    >
    >
     
    Nab, Sep 10, 2008
    #3
    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. DNB
    Replies:
    1
    Views:
    258
  2. dgleeson422111

    Consuming local web service - ok, remote web service -problem?

    dgleeson422111, Jan 26, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    908
    dgleeson422111
    Jan 26, 2010
  3. John

    Error consuming web service

    John, Jun 26, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    114
    DalePres
    Jun 26, 2004
  4. Curt K
    Replies:
    3
    Views:
    464
    John Saunders [MVP]
    Jun 15, 2007
  5. DNB
    Replies:
    1
    Views:
    310
    John Saunders [MVP]
    Jan 20, 2008
Loading...

Share This Page