locked
How to perform batch processing in Odata,, I am expecting how to fit this in code(c# or wcf 5.0) RRS feed

  • Question

  • How to perform batch processing in Odata,, I am expecting how to fit this in code(c# or wcf 5.0)

     we know that batch is for multiple operations in a single call.

     There is good information about Odata batch process  in

     http://www.odata.org/documentation/batch

    http://www.odata.org/media/30002/OData%20Batch%20Processing%20Format.html

    --batch_36522ad7-fc75-4b56-8c71-56071383e77b

    Content-Type: application/http

    Content-Transfer-Encoding:binary

    GET /service/Customers('ALFKI')

    Host: host

    --batch_36522ad7-fc75-4b56-8c71-56071383e77b

    Content-Type: multipart/mixed; boundary=changeset_77162fcd-b8da-41ac-a9f8-9357efbbd621

    Content-Length: ###      

    --changeset(77162fcd-b8da-41ac-a9f8-9357efbbd621)

    Content-Type: application/http

    Content-Transfer-Encoding: binary

    POST /service/Customers HTTP/1.1

    Host: host 

    Content-Type: application/atom+xml;type=entry

    Content-Length: ###

    <AtomPub representation of a new Customer>

    --changeset(77162fcd-b8da-41ac-a9f8-9357efbbd621)

    Content-Type: application/http

    Content-Transfer-Encoding:binary

    PUT /service/Customers('ALFKI') HTTP/1.1

    Host: host

    Content-Type: application/json

    If-Match: xxxxx

    Content-Length: ###

    <JSON representation of Customer ALFKI>

    --changeset(77162fcd-b8da-41ac-a9f8-9357efbbd621)--

    --batch(36522ad7-fc75-4b56-8c71-56071383e77b)

    Content-Type: application/http

    Content-Transfer-Encoding:binary

    GET service/Products HTTP/1.1

    Host: host

    --batch(36522ad7-fc75-4b56-8c71-56071383e77b)--

    How to implement it, please help on this



    Best Regards Showkath

    Friday, March 8, 2013 6:14 AM

All replies

  • Hi,

    Are you writing a client or a server? What technologies do you already use in there? For example, do you use the WCF Data Services libraries? If so, they already handle batch inherently.

    If not, you can use ODataLib (Microsoft.Data.OData.dll). Out of curiosity, if this is the case, why can't you use the WCF Data Services libraries?

    Thanks,


    Vitek Karas [MSFT]

    Friday, March 8, 2013 9:18 AM
    Moderator
  • Hi

    I would like to write one client ( either using c# console app using httpwebrequest or wcf data service , any one helps me. But right now i want tio start with c# consol application which send request to server ..) using c# . I am not aware how to send request to server as part of batch in terems oData standards. I hope you understand my basic requirment. I am looking for some basic stepa end request from one c# application to start my poc. My  complete requirements finally i would like to send get/post/ put.... requesta batch... like in

     http://www.odata.org/documentation/batch

    http://www.odata.org/media/30002/OData%20Batch%20Processing%20Format.html

    

    Thanks

    Showkath


    Best Regards Showkath


    Friday, March 8, 2013 5:30 PM
  • Hi,

    To start with the client library take a look here: http://msdn.microsoft.com/en-us/library/cc668772.aspx

    It can do both batch GET requests as batch updates (you didn't mention which one you're looking for, it highly unlikely you need both GET and Update at the same time).

    Thanks,


    Vitek Karas [MSFT]

    Friday, March 8, 2013 5:55 PM
    Moderator
  • Thanks for reply, Actually this is very  helpful topic if i need to implement Batching Operations  using WCF Data Services .It using  DataServiceContext, DataServiceRespons classes it sending requests (array of DataServiceRequest) to ExecuteBatch

     

    If i dont wan't to use wcf data services , Is there  any alternative instead of using wcf data service  classes , use

    HttpWebRequest, HttpWebResponse classes and perform batch operation described  in

     

    http://www.odata.org/documentation/batch

    http://www.odata.org/media/30002/OData%20Batch%20Processing


    Best Regards Showkath

    Friday, March 8, 2013 7:13 PM
  • You could use ODataLib (Microsoft.Data.OData.dll - can get it from NuGet, also part of the WCF DS). It's a low lever reader/writer for OData including batch. It's obviously much more code to use though than the WCF DS. It's kind of hard to suggest a good library to use without knowing what you're trying to achieve (Reading/writing batch is a very generic scenario).

    Thanks,


    Vitek Karas [MSFT]

    Friday, March 8, 2013 10:42 PM
    Moderator
  •  i am implementing one generic library for to send batch  requests and read batch response. Let’s assume that i have two layers                                                                                                                     

    1) Asp.net webapp  or c# windows app  as part of client side.   I would like to prepare request in client side by following OData   batch standards

    2) My server code will process request, send response as per OData standards .

    3) Client application reads this response ,parse and display this response display to end user.

    I have to concentrate on only client layer code( 1 and 3 point) . I don’t need to write code for  second layer request/response processing layer logic.  So what i m trying do is building request as per OData batch standards to send multiple requests

    After get response i need to parse output in client side only.


    Best Regards Showkath






    Friday, March 8, 2013 11:23 PM
  • If the data model represented by the service is known ahead of time I would strongly suggest you go the WCF DS Client route. It's much less code to worry about and you should be able to get something going really quickly.

    If you need to support arbitrary data models with one build of the client, then ODataLib is the way to go (as WCF DS Client cannot easily handle such cases).

    Thanks,


    Vitek Karas [MSFT]

    Friday, March 8, 2013 11:40 PM
    Moderator
  • Hi Showkath,

    Some other options you may consider include use of either Simple.Data OData adapter (Simple.Data.OData NuGet package) or Simple.OData.Client (also available on NuGet). Both of them are fairly well documented on GitHub and have support for OData batches.

    Hope this helps


    Vagif Abilov

    Friday, March 22, 2013 1:23 PM