문제

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