As far as I got it so far, OData is more meant to consume data, i.e. in a read-only manner. I want to ask whether it's intended to use OData to invoke remote functions, for example a Domain Service's method.

When looking at the OData 4.0 spec, chapter 4.3 "Addressing Entities", there are indeed terminologies like actionCall, entityFunctionCall etc. But this so far is of course also only meant for "serving", I assume.

I'd like to do something like http://example.org/service/BankAccountDomainService/ApproveBankAccount(abcde-123456)... Does that make sense?

有帮助吗?

解决方案

If I understand you correctlu, you want to invoke an unbound action, which is called "Action Import" since your action "ApproveBankAccount" does not bounded to any type.... According to the Odata Protocol, the folloding URL should be "POST": the "Account" should be included in Payload.

URL: http://example.org/service/BankAccountDomainService/ApproveBankAccount()

Payload: { abcde-123456 }

Aternatively, you can also design bounded action "Approve" on entity type "BankAccount", the posted URL should be:

http://example.org/service/BankAccountDomainService/BankAccount(abcde-12345)/NameSpace.Approve()

其他提示

OData is a standardized protocol for creating and consuming data APIs. OData builds on core protocols like HTTP and commonly accepted methodologies like REST. The result is a uniform way to expose full-featured data APIs.

Except providing functions and actions bound to entities, OData also provides service level functions and actions.

Please reference this URL for the sample: https://aspnet.codeplex.com/SourceControl/latest#Samples/WebApi/ODataActionsSample/

But it is based on OData v3, and there will soon be samples for OData v4.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top