2011-11-01 116 views
0

我問,因爲它連接到我的本地開發數據庫我的單元測試都使用的GUID沒有問題,但是當我使用通過我的WCF服務的相同方法,它失敗,出現以下異常:WCF可以處理GUID嗎?

System.Data.EntityCommandExecutionException 

我已經閱讀WCF將Guid轉換爲字符串。我確切的情況是這樣的:

代理 - >通帶的Guid

服務<對象 - 連接到數據庫,插入/檢索事情瓦特/的Guid

服務 - > GUID爲傳遞對象返回給代理

以下是錯誤從Web應用程序測試的WCF服務時:

 
[FaultException`1: An error occurred while executing the command definition. See the inner exception for details.] 
    System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +9456095 
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +345 
    BusinessServices.NGIT.ServiceContracts.IIssueTrackerService.CreateIssue(CreateIssueRequest request) +0 
    NGIT.Proxies.c__DisplayClass1.b__0(IIssueTrackerService s) in D:\NextGenIssueTracker\branches\2011Updates\NextGenIssueTracker.Proxies\Proxies\IssueTrackerProxy.cs:25 
    NGIT.Proxies.UseServiceFunction.UseService(ChannelFactory`1 channelFactory, Func`2 useService) in D:\NextGenIssueTracker\branches\2011Updates\NextGenIssueTracker.Proxies\Helpers\UseServiceFunction.cs:26 
    NGIT.Proxies.IssueTrackerProxy.CreateIssue(CreateIssueRequest request) in D:\NextGenIssueTracker\branches\2011Updates\NextGenIssueTracker.Proxies\Proxies\IssueTrackerProxy.cs:25 
    NGIT.Test.ClientProxy.Default.createIssueButtonClick(Object sender, EventArgs e) in D:\NextGenIssueTracker\branches\2011Updates\NGIT.Test.ClientProxy\Default.aspx.cs:36 
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563 

這裏是從跟蹤的內部異常Viewer:

 
System.Data.EntityCommandExecutionException, System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
An error occurred while executing the command definition. See the inner exception for details. 

at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) 
at System.Data.Objects.ObjectContext.CreateFunctionObjectResult[TElement](EntityCommand entityCommand, EntitySet entitySet, EdmType edmType, MergeOption mergeOption) 
at System.Data.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, MergeOption mergeOption, ObjectParameter[] parameters) 
at System.Data.Objects.ObjectContext.ExecuteFunction[TElement](String functionName, ObjectParameter[] parameters) 
at NGIT.Data.UserIssueEntities.CreateIssue(String issueTitle, String nextGenUserId, Nullable`1 guid) in D:\NextGenIssueTracker\branches\2011Updates\NextGenIssueTracker.Data\UserIssueObjectGenerator.cs:line 305 
at Liberty.DataAccess.NGIT.SqlUserIssueRepository.AddIssue(User user, Issue issue) in D:\NextGenIssueTracker\branches\2011Updates\DataAccess.NextGenIssueTracker\Repositories\SqlUserIssueRepository.cs:line 51 
at BusinessServices.NGIT.ServiceImplementations.IssueTrackerService.CreateIssue(CreateIssueRequest request) in D:\NextGenIssueTracker\branches\2011Updates\BusinessServices.NextGenIssueTracker\ServiceImplementations\IssueTrackerService.cs:line 59 
at SyncInvokeCreateIssue(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) 


+0

異常類型意味着這是一個與數據相關的異常。你能發佈完整的異常(消息,鍵入+堆棧跟蹤)嗎? –

+0

我不確定GUID數據類型是否可互操作。你試過用一個字符串代替嗎? –

+0

「EntityCommandExecutionException」的內部異常是什麼? – svick

回答

1

Yes.(.NET GUID - > Java的String)

當然,什麼是真正的問題不能與你發佈正是決定。

+0

非常有用的鏈接,非常感謝 – Didaxis

+0

保留書籤,因爲如果你打算把你的服務暴露給Java客戶端,它非常方便的知道他們應該期待什麼以及你會遇到什麼問題。 –

1

我已經使用WCF與基於GUID的實體沒有任何問題。我不認爲這是你的問題,或者與WCF有關的事情。這聽起來更像是在數據庫層面的問題:

EntityCommandExecutionException 表示當底層的存儲供應商無法執行指定的命令時發生的錯誤。這個異常通常會包裝一個提供程序特定的異常。