开发者

Accessing a WCF service from ASP.NET 2.0

I'm trying to access a WCF service, exposed using basicHttpBinding, inside an ASP.NET 2.0 web application. The services uses Entity Framework 4.0, and its business entities were created using the ADO.NET Self-Tracking Entity Generator T4 template. I can attach to the service from the ASP.NET 2.0 app just fine and compile, but at run time, when I try to call the service to save, I get the following error:

The formatter threw an exception while trying to deserialize the me开发者_高级运维ssage: There was an error while trying to deserialize parameter http://tempuri.org/:foc. The InnerException message was 'The use of type 'Business.App.ObjectChangeTracker' as a get-only collection is not supported with NetDataContractSerializer. Consider marking the type with the CollectionDataContractAttribute attribute or the SerializableAttribute attribute or adding a setter to the property.'. Please see InnerException for more details.

I don't have anything fancy on the service declaration; just the normal ServiceContract and OperationContract attributes.

[ServiceContract]
public interface ILSRPipelineServiceEndPoint
{
    [OperationContract]
    LSRRequestTypeMapping[] GetRequestTypeMappings();

    [OperationContract]
    LSRResponseTypeMapping[] GetResponseTypeMappings();

    [OperationContract]
    ServiceResult<FOCResponse> ValidateFOC(FOCResponse foc);

    [OperationContract]
    ServiceResult<FOCResponse> SendFOC(FOCResponse foc);

    [OperationContract]
    ref_SourceType GetGatewaySourceType();
}

All of the objects shown are marked with [DataContract(IsReference = true)]

Any ideas what I'm doing wrong, or what I can do to resolve this? Thanks a ton, all!


I think the problem is that you're using the NetDataContractSerializer rather than the DataContractSerializer. From what I've read only the DataContractSerializer is supported for self-tracking entities.

See this page:MSDN thread


I ultimately changed to using View Model POCO's, rather than trying to send across the raw objects with their state tracking components. Thanks, all! Lesson learned.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜