Didaxis
Didaxis

Reputation: 8746

Can WCF handle GUIDs?

I ask because my unit tests which connect to my local dev database have no problem using Guids, but when I use the same methods via my WCF service, it fails with the following exception:

System.Data.EntityCommandExecutionException

I've read the WCF converts Guids to strings. My exact scenario is this:

Proxy -> pass object with Guid

Service <- connect to db, insert/retrieve things w/Guid

Service -> pass object with Guid back to proxy

Here is the error when testing the WCF service from the web application:

[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

And here is the inner exception from Trace 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)


Upvotes: 0

Views: 2491

Answers (2)

myermian
myermian

Reputation: 32515

Yes. (.NET GUID -> Java String)

Of course, what is the actual issue can not be determined with just what you posted.

Upvotes: 1

Joel C
Joel C

Reputation: 5567

I've used WCF with GUID-based entities without any issues. I don't think that's your problem here, or anything to do with WCF for that matter. This sounds more like an issue at your database level:

EntityCommandExecutionException Represents errors that occur when the underlying storage provider could not execute the specified command. This exception usually wraps a provider-specific exception.

Upvotes: 1

Related Questions