I have an OData service based on the Web Api 4, and I wan't to add an action to this service, but the action method is generic, so is this supported?
Thanks
No, the OData protocol does not support generics for actions or functions. You'll need to create a separate action for each type you want to support, unfortunately.
You can publish context-level service operations (function imports) using WCF Data Services... this requires to migrate your code from WebAPI.
Related
I've one missing link to understood how it could work to "connect" my EF core's DbContext to different applications in following scenario:
I've got one application project which contains the whole EF Core Code first datamodel (Entities, Business Logic, Enums etc).
Until now we're using a WebAPI application to share data with multiple endpoints.
So the data we're exchanging now are quite static at the moment. We create our DbContext and the API is using it for data reading and write operations.
Now there is customer request to also build a WebUI (Blazor). So we still want to use the WebAPI for data exchange in the UI, but further we need some more business logic elements from our data model (containing INotifyPropertyChanged event handling etc). We implemented the event handles in the entity classes. So we intend to build a session object for each user/client which contains the DbContext instance. But how can handover an instantiated DbContext from the Web API to my UI Application.
Would be nice to get some input. Thx for any advice.
You do not pass the DBContext object to "UI Application", such as a Blazor app.
You did not mention what flavor of Blazor you are using... However, the following may be applicable for both Blazor Server App and Blazor WebAssembly App... From what I've gather from your question you are exposing Web Api end points to retrieve data and save data. This is good. What is left for you to do is to create code in your Blazor that access those end points. You should use the HttpClient service to do this. If you use Blazor client side, this object is configured and made available for injection in your components and services. This type of HttpClient is based on the JavaScript Fetch Api.
If you are going to create a Balzor Server App, then you'll have to add the HttpClient service to the DI container and configure it accordingly, and only then you'd be able to inject it into your components and services. In this case you should use the IHttpClientFactory to provide the HttpClien onjects.
In principle, you have to query your Web Api methods via HttpClient.
Note that if you use Blazor Server App, you don't have to use Web Api. Instead you can create services that perform similar functionality to that provided by the Web Api.
Please, go to the docs and acquaint yourself how to use the HttpClient with Blazor apps.
Hope this helps...
I wanted to use all the wso2 functionalities from my own customised UI. Is it possible to do so? If yes, them how to do it?
The scenario is: I don't want to use the available wso2 pages instead I wanted to have my own theme. How to do it?
WSO2 products up to carbon 4 are based on carbon osgi services. These services exposed as SOAP web services which known as admin services. You can refer WSO2 IS documentation to get idea how those can be enabled to outside and invoke [1]
You can create any application and invoke those SOAP web services. Although there are workarounds to invoke SOAP web services from HTML JS, best approach would be use a server side language like JSP and invoke web services from there. From front end HTML JS, you can use AJAX to call those JSP resources.
[1] https://docs.wso2.com/display/IS510/Calling+Admin+Services
If you are referring to your own UI like the BPMN explorer that ships with WSO2 BPS, you can use the BPMN REST api [1] for this. This documentation [2]explains how the existing UI works. You can build your own by invoking the Rest API.
[1] - https://docs.wso2.com/display/BPS360/BPMN+REST+API
[2] - https://docs.wso2.com/display/EI610/Customizing+BPMN+Explorer
Can we use BreezeJS or JayData, with all of their features without OData (i.e using only ASP.NET Web API but without OData)?
Breeze already supports this as it's default. Breeze, by default, uses an OData format over the wire for query purposes, but this does NOT require that the server be implemented as an OData service. The standard Breeze WebApi server controller can understand this format without you having to implement an OData service. ( the same is true of our Mongo and Ruby server examples).
In fact, most of the Breeze examples show Breeze communicating directly with ASP.NET Web Api without using any of the WebApi OData implementation.
We have some legacy OData service code in our application which is written using a WCF Data Service.
Everything else in our system now uses Web API as the data interface so I am wanting to port our WCF OData Service to a Web API service with the OData annotations.
My question is, we currently use the OData service for standard CRUD statements and also a lot of Service Operations. Are there any limitations with Web API OData that would limit it compared to WCF Data Services (i.e relationship chains, service operation calls, etc.)? I'm wanting to get away with updating the service so the client side of things doesn't have to change at all.
I've started working on a similar port from WCF to WebAPI for OData with the recent release of Web API 2 and its support for $select and $expand - until then I could not really replace the data service. Service operations can be added as actions
I have been catching up with MVC4 Web API and WCF Data Service. From the surface, they both seem to be able to work with oData in the consuming client. I wonder which one is better for separation of concern (separate data service layer from UI layers). In my current solution, I have a plain MVC 3 style Intranet project and a MVC Data Service project. The 1st project has a Service Reference to the 2nd project. My goal is to write the data service once and make it available to all projects that would need to access underline database. When I read about Web API, it seems to me that the ApiControllers can return oData compliant result to the consuming client without MVC Data Service. My confusion is how I am going to expose this Web API MVC project as a service endpoint. Should I wrap it in WCF? Thanks.
You just create a controller inheriting ApiController and decorate one action with [Queryable] attribute, Rest depends on your route setup. Easy-Peasy.
Which one better? Web API. Since it has all the goodness of HTTP and you are not restricted to ATOM format.
You may use PocoHttp for seamless access of the data from your client.