1
votes

I've updated my model and done rebuilding the project (as suggested by stackoverflow) but no benefit.

My ASP.NET wcf webservice is working fine on local host. But when I upload it to AppHarbor (free asp.net web hosting service) I get an exception (I'm calling like this http://pizzaapp.apphb.com/Service1.svc/Login/123/1) which I can't understand (shown below). This works perfectly on my localhost, so what's the problem after uploading?

Request Error The server encountered an error processing the request. The exception message is 'An error occurred while executing the command definition. See the inner exception for details.'. See server logs for more details. The exception stack trace is:

at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues) at System.Data.Entity.Core.Objects.ObjectQuery1.<>c__DisplayClass3.<GetResults>b__2() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectQuery1.<>c__DisplayClass3.<GetResults>b__1() at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1 operation) at System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) at System.Data.Entity.Core.Objects.ObjectQuery1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at System.Lazy1.get_Value() at System.Data.Entity.Internal.LazyEnumerator1.MoveNext() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.b__2[TResult](IEnumerable1 sequence) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable1 query, Expression queryRoot) at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression) at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression) at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source) at WcfServicePizza.Service1.Login(String phoneNo, String password) in d:\temp\lmtrshzg.bwx\input\WcfServicePizza\Service1.svc.cs:line 37 at SyncInvokeLogin(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

The code for the webservice interface

    [OperationContract]
    [WebInvoke(UriTemplate="SignUp",
        Method="POST",
        BodyStyle=WebMessageBodyStyle.WrappedRequest,
        ResponseFormat=WebMessageFormat.Json,
        RequestFormat=WebMessageFormat.Json)]
    bool SignUp(Customer customer);

And code for its implementation running on the server currently is:

    public bool Login(string phoneNo, string password)
    {
        decimal phoneNoDecimal = Decimal.Parse(phoneNo);
        DatabasePizzaEntities db = new DatabasePizzaEntities();
        Customer customer = db.Customers.Where(c => c.PhoneNo==phoneNoDecimal && c.Password == password).SingleOrDefault();
        if (customer == null)
            return false;
        return true;
    }

INNER EXCEPTION:

Data.SqlClient.SqlException (0x80131904): Invalid object name 'dbo.Customer'.\u000d\u000a at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)\u000d\u000a at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)\u000d\u000a at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\u000d\u000a at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\u000d\u000a at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()\u000d\u000a
at System.Data.SqlClient.SqlDataReader.get_MetaData()\u000d\u000a at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)\u000d\u000a at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)\u000d\u000a at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean asyncWrite)\u000d\u000a at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)\u000d\u000a at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)\u000d\u000a at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)\u000d\u000a at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\u000d\u000a at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<>c__DisplayClassb.<Reader>b__8()\u000d\u000a at System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch[TInterceptionContext,TResult](Func1 operation, TInterceptionContext interceptionContext, Action1 executing, Action`1 executed)\u000d\u000a at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)\u000d\u000a at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)\u000d\u000a at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)\u000d\u000a at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)\u000d\u000aClientConnectionId:2c6eb8fd-ce5b-4866-8dc7-5ff565fb11d5\u000d\u000aError Number:208,State:1,Class:16"

1
what is inner exception?Manish Parakhiya
The error is in the server, not in wcf, do you connect with the same DB in the 2 envirements?Elisheva Wasserman
@ Manish Parakhiya How to see the inner exception? @ElishevaWasserman I'm only changing the connection string.Musarrat Saeed
Without knowing the inner exception this question is useless. Look in the server's event log or improve your logging.Gert Arnold
I've added the inner exception. I do have Customer in ADO.net Entity Data model. Then why am I getting this?Musarrat Saeed

1 Answers

1
votes

The difference between local host and AppHarbor is which database you are connecting to.

The error message is:

An error occurred while executing the command definition

This is generally a problem between your database schema and your mapping files.

Is the database Schema In AppHarbor different from that in your local database?

This is "Invalid Object Name", either:

  • the Customer table is not there,
  • or it is not in the dbo schema,
  • or the user in the connection string does not have rights to access the table.