locked
WCF Data Services and HTTP request interception/handling for REST verbs? RRS feed

  • Question

  • UPDATE: Asking in a different way in hopes to get response :

    Is there a way to intercept request processing?  As is done in WCF via:

     

     

    public class MyService : RequestInceptor
    {
    public override void ProcessRequest(ref RequestContext requestContext)
    {
    // ...
    }
    
    }
    

     

     

    Original question:

    How does WCF Data Services team handle supporting all the HTTP verbs (PUT, DELETE, ETC.) for REST ?  I ask because I cannot create an HTTP DELETE from my Silverlight client in trying to invoke a WCF Data Services service operation.

    I noticed when I delete an object with WCF Data Services client library, the proper HTTP verb was sniffed (see below), however, Silverlight/Browsers seem to not support this verb.

    EDIT: I did notice _no_ support for DELETE on service operations  ( has that changed ?? ) from this post (http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/e546042f-c5f7-489d-b3e7-03b84a4f07ab ) 

     

     

    DELETE http://localhost.:2483/Foo.svc/People(20) HTTP/1.1
    
    User-Agent: Microsoft ADO.NET Data Services
    
    DataServiceVersion: 1.0;NetFx
    
    MaxDataServiceVersion: 2.0;NetFx
    
    Accept: application/atom+xml,application/xml
    
    Accept-Charset: UTF-8
    
    Content-Type: application/atom+xml
    
    Host: localhost.:2483
    
    Content-Length: 0

     

     

    • Edited by Rybolt Monday, December 20, 2010 2:07 PM formatting
    Friday, December 17, 2010 7:38 PM

Answers

  • Hi,

    WCF Data Services when hosted inside a WCF service (the default when you create the service through VS templates) uses service contract with a single operation which is marked to handle all incomming requests for a certain virtual path (the service URI). It will then handle those verbs which it supports, that is:
    - GET, POST, PUT, MERGE, DELETE for entities or entity sets
    - GET, POST for service operations

    Currently service operations are not supported for the DELETE verb. If you want to create a service operation which modifies some state then the suggested solution is to use a POST service operation.

    From the client side DELETE should work just fine, if it does not could you please share more details with us about your environment and how you issue the request in question?

    If your network environment doesn't support DELETE for some reason you can also ask the client to use POST tunneling by setting the DataServiceContext.UsePostTunneling to true, then all write requests (POST/PUT/DELETE) will be sent using POST verb on the outside.

    Thanks,


    Vitek Karas [MSFT]
    • Marked as answer by Rybolt Tuesday, December 21, 2010 3:04 PM
    Tuesday, December 21, 2010 2:53 PM
    Moderator

All replies

  • Hi

    As far as I know, it supports well all the verbs of REST.  It does not change.

    Pam

    Tuesday, December 21, 2010 3:14 AM
  • Hi,

    WCF Data Services when hosted inside a WCF service (the default when you create the service through VS templates) uses service contract with a single operation which is marked to handle all incomming requests for a certain virtual path (the service URI). It will then handle those verbs which it supports, that is:
    - GET, POST, PUT, MERGE, DELETE for entities or entity sets
    - GET, POST for service operations

    Currently service operations are not supported for the DELETE verb. If you want to create a service operation which modifies some state then the suggested solution is to use a POST service operation.

    From the client side DELETE should work just fine, if it does not could you please share more details with us about your environment and how you issue the request in question?

    If your network environment doesn't support DELETE for some reason you can also ask the client to use POST tunneling by setting the DataServiceContext.UsePostTunneling to true, then all write requests (POST/PUT/DELETE) will be sent using POST verb on the outside.

    Thanks,


    Vitek Karas [MSFT]
    • Marked as answer by Rybolt Tuesday, December 21, 2010 3:04 PM
    Tuesday, December 21, 2010 2:53 PM
    Moderator