I'd like to be able to have my BreezeController on the server side also be accessible by standard OData clients. I saw there was a question almost a year ago that was answered saying this was coming to breeze here. However, when I point an OData client (such as LinqPad or Excel) to my server it has an issue since the metadata isn't correct. This is even after changing the metadata action name on the controller to "$metadata". Am I correct in believing that a Breeze WebApi2 controller can act as an odata endpoint?
Hang in there, #cobywhite. We're about to release a Web API 2 OData sample that will show you how. Maybe by end of this week or top of next week.
You will have to make a small change on the OData server to get it to deliver the proper metadata. Are you able to do that?
As for reusing the "BreezeController" ... that's going to be tricky. OData is very particular about having its own controllers. I think you'll have to write those too. Make sure you don't put any business logic in any of your controllers. You shouldn't be doing that under any circumstances but now it will be imperative.
Always delegate to a repository or unit-of-work-and-repositories. The controllers should focus exclusively on their roles as vehicles and gatekeepers for communication with clients.
Related
my first question on StackOverflow, so apologies if not perfect right from the beginning ...
My question is actually two-fold:
Can I have the LightSwitch ApplicationData service (or any other internally defined Data Source) define ODATA actions on the service level or entity set/entity level? If yes, how do I do that? (I cannot find the route information in the application where I could override/add that.)
How would I consume these actions from the client side (via the built-in MS JS object model in msls or via screen/entity)? Even, if LightSwitch itself could not create/would not support actions, I would still like to know how to consume them from the client side, as we are exposing external ODATA data sources via LightSwitch to the client (and these ODATA source have actions defined).
I know I can use jaydata from the client side to consume that and execute actions on an ODATA source, but I would like to know if LightSwitch has built-in support for that.
Further information: we are using VS/LS 2013. And Silverlight is not an option, we only use the HTML client.
Thank you very much for your support and hints!
Regards, Ronald
There is nothing built-in to LightSwitch that lets you define custom OData actions on the service side or consume them from the client side. You'd need to use standard web functionality like ASP.NET's WebAPI and your favorite JavaScript OData library, like JayData.
I have a fairly simple MVC4 web application that accepts HTTP POST requests. The Controller responsible for the managing the POST request simply parses the form collection and creates an appropriate record in a SQL database table.
I would like to extend my application to provide an administration page that automatically updates each time a new POST is recorded. For the page architecture for this facility I was planning to use SignalR. I've used SignalR before, so I am fairly happy with the basic Hub/Client interaction, but what I don't know is what 'plumbing' I can use to get the SignlR Hub to monitor the events on the POST Controller or to put it another way, what the POST Controller needs to do to trigger some kind of event that the SignalR Hub can respond to.
I hope this makes sense, any suggestions would be much appreciated.
This is what you're looking for http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-server#callfromoutsidehub
plaese guide me to start asp.net mvc 4 ajax enabled multi platform web application. I have a REST service hostrd in another domain, want to consume it. please guide me whether i need to access that service from javascript ajax call or
create models at server and request my server with ajax call. any guides links much appreaciated..
regards
ani
The exact way to consume your web service will depend on the content of this service, and how you want the user to interact, but, from my point of view, the server should be interacting with the webservice, and your user with your server. That is, as you guessed, "models" should reflect your web service data structure.
If you want to use ajax, use it to call methods in your controller(s) to load/update data from the webservice.
It's a bit difficult for me to go further without knowing what we are talking about, but to give you a better idea of what I am talking about, I wrote my own "API" to deal with Amazon Products Advertising API, using their rest service instead of SOAP. This same API is being used by 3 differents web applications.
Inside each web application there are AJAX calls to controller methods, who in turn calls my API methods.
This mechanism works perfectly in this case, but it may not in yours, which is why I believe you need to tell us a little more about hte kind of service and application you are going to build.
Sorry to stay a little vague, still hope this helps.
Bernard
A fundamental idea in implementing a single page application with Knockout and Upshot is that most of the data will received from and sent to the server in JSON format using AJAX.
On the server, we will expose a number of endpoints (using perhaps WebAPI and the DbDataController) to respond to requests from Upshot. These endpoints may provide general queries for data such as lists of clients, previous orders, account information, etc.
Obviously, it is not desirable for one client to be able view another clients account information, previous orders, or other private data.
What strategies or approaches be used to secure queries (and data) which are being requested from upshot (or other mechanism) to the server? (In other words, how do we make sure a user only has access to his own data?)
Are the strategies the same or different than those used in a normal ASP.NET MVC application--namely use of the Authorize attribute?
This is probably a very simple question, but I am still not clear on all the differences between WebAPI controllers and normally ASP.NET MVC controllers.
Thank for your help!
A custom authorize attribute is one possible way to implement this requirement. The only difference with standard ASP.NET MVC controllers is that you derive from System.Web.Http.AuthorizeAttribute instead of System.Web.Mvc.AuthorizeAttribute.
A 3rd party site sends its notifications after my web application has completed some action in order to notify me of its success. Receiving a notification item requires a response back to the 3rd party server (URL) with the a containing the value "accepted".
I have never user SOAP and with the basic info found I'm a bit lost for the case of asp.net mvc. Are there any good links showing the principle of receiving and sending SOAP responses?
Tutorials / information may be presented in other languages such as java, asp.net (classic) or something. I need to get a general idea since googling on SOAP has not given me anything for the past few hours.
You need to learn a little about WCF. See the WCF Developer Center, especially the Beginners Guide.
What you want is to create a simple WCF service that corresponds to the WSDL that they will give you. You will need to implement only the operation (method) that they will call to notify you. You can host a WCF service in IIS along with the rest of your application.
The issue will be how to correlate the notifications with the page you're on in your MVC application.
I don't think this is specific to ASP.NET MVC really. If you have a WSDL for their web service, just use that to generate stub classes using either wsdl.exe or by adding a web reference to your project, then call the web service from your controller.
If I remember correctly SOAP is basically xml requests and responses.
You might want to look into WSDL (Web Service Definition Language) to avoid having to deal with raw data, and you would likely find a great deal of tutorials on wsdl as well.