locked
Invalid XML with two feed elements returned after a few requests RRS feed

  • Question

  • Hi,

    I'm accessing a normal data collection in a WCF dataservice, and initially everything works fine. I receive the data correctly and can view the xml in a browser or a tool like LinqPad. But after a few requests, 6 or 9, I'm starting to receive an invalid xml. The feed element is two times in the xml. All subsequent requests on the same collection have this problem. But when I access another collection the process repeats itself. I get 6 or 9 correct results, and then it starts to fail again.

    I'm using an Entity Framework code-first approach. My custom context that's inherited from DbContext is the generic parameter of the DataService<T> class. I let the framework create an instance of this class. 

    What am I doing wrong, or how can I work around this?

    Below are two responses that I captured with fiddler. The first response returned a correct feed, whearas the second response (request 9 in this case) returned an invalid xml.

    HTTP/1.1 200 OK
    Cache-Control: no-cache
    Content-Length: 1620
    Content-Type: application/atom+xml;type=feed;charset=utf-8
    Server: Microsoft-IIS/8.0
    DataServiceVersion: 1.0;
    Date: Tue, 21 Aug 2012 11:44:37 GMT

    <?xml version="1.0" encoding="utf-8"?>
    <feed xml:base="http://localhost:51612/DataCatalogService.svc/"
     xmlns="http://www.w3.org/2005/Atom"
     xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
     xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <id>http://localhost:51612/DataCatalogService.svc/Users</id>

    HTTP/1.1 200 OK
    Cache-Control: no-cache
    Content-Length: 1620
    Content-Type: application/atom+xml;type=feed;charset=utf-8
    Server: Microsoft-IIS/8.0
    DataServiceVersion: 1.0;
    Date: Tue, 21 Aug 2012 11:44:40 GMT

    <?xml version="1.0" encoding="utf-8"?>
    <feed xml:base="http://localhost:51612/DataCatalogService.svc/"
     xmlns="http://www.w3.org/2
    <?xml version="1.0" encoding="utf-8"?>
    <feed xml:base="http://localhost:51612/DataCatalogService.svc/"
     xmlns="http://www.w3.org/2services/metadata">
    <id>http://localhost:51612/DataCatalogService.svc/Users</id>

    Thanks

    Thomas

    Tuesday, August 21, 2012 1:13 PM

Answers

  • I finally isolated the cause of this behavior.

    When you have WCF tracing configured and you have set logMessagesAtTransportLevel to true, you get this behavior.

    • Marked as answer by Thomas Smets Thursday, August 23, 2012 6:34 AM
    Thursday, August 23, 2012 6:34 AM

All replies

  • I finally isolated the cause of this behavior.

    When you have WCF tracing configured and you have set logMessagesAtTransportLevel to true, you get this behavior.

    • Marked as answer by Thomas Smets Thursday, August 23, 2012 6:34 AM
    Thursday, August 23, 2012 6:34 AM
  • Thanks for the workaround! This also caused the problem for me. Setting logMessagesAtTransportLevel  to false fixed the issue. 
    Tuesday, September 8, 2015 6:54 AM