An interesting problem was discovered when using the WCF service data client library to request data from the WCF data service

I have a simple data model with 3 tables (Account, Contact and User) with the following relationships:

User β†’ account (1 - many) β†’ contact (many - 1)

I view my data through the OData (v3) WCF data service, which is consumed by the .NET client, which uses the WCF data services client library. I used the Add Service utility to create a client proxy to invoke the data service.

All client class methods use the same DataServiceContext class to invoke the web service. i.e:.

 DC.WhEntities svcClient = new DC.WhEntities(new Uri(BaseUrl)); 

What I'm struggling to figure out is why the same service request request starts crashing after the 6th time. I literally tried all possible ways to build a data service call:

First approach:

 DataServiceQuery<DC.User> users = svcClient.Users.Expand("Accounts"); QueryOperationResponse<DC.User> response = users.Execute() as QueryOperationResponse<DC.User>; var user = response.FirstOrDefault(u => u.Id == long.Parse(key.ToString())); 

Second approach:

 string queryString = string.Format("Users({0}L)?$expand=Accounts", key.ToString()); foreach (var user in response) {...} 

The last statement in both of the above solutions starts to crash after the message after it has successfully completed 6 times in a row:

 The response payload is a not a valid response payload. Please make sure that the top level element is a valid Atom element or belongs to 'http://schemas.microsoft.com/ado/2007/08/dataservices' namespace. **StackTrace:** at System.Data.Services.Client.Materialization.ODataMaterializer.CreateODataMessageReader(IODataResponseMessage responseMessage, ResponseInfo responseInfo, Boolean projectionQuery, ODataPayloadKind& payloadKind) at System.Data.Services.Client.Materialization.ODataMaterializer.CreateMaterializerForMessage(IODataResponseMessage responseMessage, ResponseInfo responseInfo, Type materializerType, QueryComponents queryComponents, ProjectionPlan plan, ODataPayloadKind payloadKind) at System.Data.Services.Client.DataServiceRequest.Materialize(ResponseInfo responseInfo, QueryComponents queryComponents, ProjectionPlan plan, String contentType, IODataResponseMessage message, ODataPayloadKind expectedPayloadKind) at System.Data.Services.Client.QueryResult.ProcessResult[TElement](ProjectionPlan plan) at System.Data.Services.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents) 

When this happens, my WCF data service just stopped working and returns a response using

in row 1 in column 83: Unescaped '<' is not allowed in attribute values.

I’m not sure that I don’t have anything fundamental either if I incorrectly create a WCF data service client request or if there is something in the WCF Data Service that does not like the same client requesting the same thing 6 times.

I have already spent several days, and I had in mind 3+ days trying to figure it out. I am new to WCF data service, and it seemed to me that I could learn from this lesson, but so far I have more pain than amplification.

+4
source share
2 answers

I tried setting logMessagesAtTransportLevel to false and still got the error.

Then I remembered that I had seen this question before when I had a build conflict. I went and created a completely new service, and this solved my problem even when I had logMessagesAtTransportLevel set to true on my client. This ensured that the problem was maintenance.

Although my solution solved my problem, I still do not know the exact problem, and I did not have enough time to find out. Nevertheless, it’s good to see that people are ready to help, and I really appreciate the effort.

Thank you all for your help.

Qster123.

0
source

I am experiencing a similar problem, suddenly my server started (maybe some updates caused this, but the reason is unknown) in order to return bad answers. If I started my server, it works for a while, say, it answers several requests in the usual way, and then it starts interrupting the structure of the XML array of OData feeds, which leads to < , the hexadecimal value 0x3C , is an invalid attribute symbol, Line 2, position 72. exception .

DECISION:

I solved the problem by running this feed

If you have WCF tracing configured, make sure logMessagesAtTransportLevel="false" turned off, otherwise you will run into this problem.

+3
source

Source: https://habr.com/ru/post/1435198/


All Articles