Passing List<> from webservice (works on local machine but not on production)

Last post 07-03-2009 7:51 AM by robertdondo. 2 replies.

Sort Posts:

  • Passing List<> from webservice (works on local machine but not on production)

    07-03-2009, 5:42 AM
    • Member
      4 point Member
    • robertdondo
    • Member since 07-03-2009, 5:30 AM
    • Posts 4

    Hi all,


    I am calling a webservice to return a List<>, with the following code:

    [WebMethod()]
            public List<JobCategory> GetJobCategories()
            {
                return FieldLookup.GetJobCategories();
            }


    This method calls another static method (fieldlookup) from the mid-tier and passes on the List<JobCategory>.


    When I run it on my testing server, everything works 100%. When I deploy to production, however, I get the following error (for this web method only, other methods are working):

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
      at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
      at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
      at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject)
      at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
      at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
      at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
      at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
      at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
      at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
      at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
      at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
      at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
      at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
      at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
      at System.Data.SqlClient.SqlConnection.Open()
      at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
      at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()
      at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
      at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
      at System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
      at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
      at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
      at Nestle.CommunityPassport.MidTier.Helpers.FieldLookup.GetEmploymentTypes() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Nestle.CommunityPassport\Nestle.CommunityPassport\Nestle.CommunityPassport.MidTier\Helpers\Lookup.cs:line 16
      at Nestle.CommunityPassport.WebService.NcpService.GetEmploymentTypes() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\Nestle.CommunityPassport\Nestle.CommunityPassport\Nestle.CommunityPassport.WebService\Ncp.asmx.cs:line 476
      --- End of inner exception stack trace ---

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  • Re: Passing List<> from webservice (works on local machine but not on production)

    07-03-2009, 6:54 AM
    Answer
    • All-Star
      20,683 point All-Star
    • qwe123kids
    • Member since 03-27-2008, 5:49 AM
    • Posts 3,515

    Hi,

    Real Error is mention below...

    System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

    Have Checked Connection string username,Password,Databasename,and Ipaddress

    Thanks
    Avinash Tiwari

    Remember to click “Mark as Answer” on the post, if it helps you.

    MY Blog

    Hacking Inside .net exe
  • Re: Passing List<> from webservice (works on local machine but not on production)

    07-03-2009, 7:51 AM
    • Member
      4 point Member
    • robertdondo
    • Member since 07-03-2009, 5:30 AM
    • Posts 4

    thanks a lot, fixed it, i was using a wrong connection string in that particular method. Everything is now in order, appreciate your help.

Page 1 of 1 (3 items)