I need to store data received from a remote device, i.e Application needs to run 24 hours so that it can capture data and store it in database.
I am confusing whether to create a console application, web application or any other i need to develop which will run continuously.
If you already have the application developed, then send the data to a web service. if you don't, consider creating a web page, either using ASP.Net or something like JQuery Mobile and push data to HTTP Handlers or Web Service.
If you go down the web service route, create a web method that accepts a request object and returns a response object. It should be a pretty simple design.
Related
This is my situation, I need to get a data from a smart card through a client application, after that I need to pass that data to my web application written in VB.NET(Asp.NET). I've read that its possible to do it with WCF Service but couldn't really figure it how. I've google about it but all the tutorial only tell process of web application and web service. But in my case, it is client application to web services to web application.
Any help/suggestion is appreciated. Thanks in advance.
For your client application (for example, a winform), take a look at this:
Smart card reader development with .Net technologies
You can after that create a WCF or REST api that will receive your request after reading whatever you need from your smart card (from your client application):
https://learn.microsoft.com/en-us/aspnet/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api
Finally, you have to send your data from your client application to your webapi:
How do I make calls to a REST api using c#?
Note: If you want to create a wcf instead of the web api, take a look at this:
https://www.codeproject.com/Articles/42643/Creating-and-Consuming-Your-First-WCF-Service
Let me know if you need more info. Also, provide more information about what you already have and what you don't (do you have the client application?)
I need to develop windows service which will do fortnightly transfers of files into the system. The problem is that I will also need "RunNow" method, so users can call transfer method any time by clicking to the link in the web app (asp.net mvc).
How can I call my windows service methods from external resource?
If you want to call a windows service method on the server side of your web application then take a look at the WCF or RestSharp and Nancy. Shortly, you need to create a RESTfull service in the windows service application that will be using a http://localhost/myservice/transfer address to expose the Transfer method. Then use ajax from your javascript code or RestRequest from your .net-controller class to call the address.
But if you want to call a windows service method on the client side of the application it will be a problem.
You could use Microsoft Message Queuing
The Webapplication would send a Message that the Service picks up.
Queue-Based Background Processing in ASP.NET MVC Web Application
http://msdn.microsoft.com/en-us/library/ms978430.aspx
I have a PC based application and mobile app that both send data to my MVC Web API. I was wondering if anyone tracks which application inserted data to the server database?
For instance, when I send data from the mobile app, I mark a IsMobile flag in my table when I insert data.
If the answer is yes, can you briefly explain how you accomplish this and what issues it may have saved you from?
You could make this as parameter in your web api call and the mobile client sends it with the value "mobile" and the PC sends it as "PC"
In the MVC controller this comes as a variable and then you can store it.
I decided to use the User-Agent route. I am now creating a log the inserts the HttpContext.Current.Request.UserAgent from every request made to my web API. Here is a link that helped me out.
After searching the entire day about what I should use, I'm not sure what option would be best for my needs so I hope someone with more experience could help me out.
I have a winforms application (c#) and a ASP.NET MVC 4 web application (c#).
I wish to connect these, the goal is to send and receive data from the database which I use in the MVC 4 project, but from within the windows forms application. The data I send from the windows forms application to the database, is then used by the MVC 4 web application.
I am entirely new to web services / Web Api's so I can't really decide what option would be best. Any help would be much appreciated..
If you already created MVC4 project then you can add actions to any controller
and return JSON data like below :
public JsonResult GetCategoryList()
{
var list = //return list
return Json(list, JsonRequestBehavior.AllowGet);
}
or you can create new project of MVC4 and select WEBAPI template . It will create webapi project for you .It will create with example .so it will easy for to create webapi.In webapi it return data automatically convert to xml and json as per request
The WCF Web API abstractions map to ASP.NET Web API roughly as follows
WCF Web AP -> ASP.NET Web API
Service -> Web API controller
Operation -> Action
Service contract -> Not applicable
Endpoint -> Not applicable
URI templates -> ASP.NET Routing
Message handlers -> Same
Formatters -> Same
Operation handlers -> Filters, model binders
Other Links
If you have an MVC 4 App already, it would be better to use Web API (RESTful service)
I assume you have some knowledge in building REST API (understanding of POST, PUT, UPDATE stuff)
It is simple in configuration and usage. All what you need actually is to create a new controller like:
class MyApiController: ApiController {
public Post(SomeClass item) {
....connect to db and do whatever you need with the data
}
}
You'll also should configure routing for Api.
And then in your winForms app you can simply use HttpClient class to perform api call.
HttpClient aClient = new HttpClient();
// Uri is where we are posting to:
Uri theUri = new Uri("https://mysite.com/api/MyApi");
// use the Http client to POST some content ( ‘theContent’ not yet defined).
aClient.PostAsync(theUri, new SomeClass());
Take a look at some implementation details right here:
Web Api Getting Started
Get started with WCF is not so easy as with Web API.
Given the tags you've used, my guess is that you're deciding between SOAP Web Services and WCF. Given these two, I say to go WCF. SOAP web services (as implemented in Visual Studio) are the older technology; still serviceable, but WCF can do everything an older SOAP service can do (including look exactly like a SOAP service) and more.
If you have a web service that connects your web server to your database server (these two things should be on different machines; your web server is exposed to the world by necessity, while your DB server should be locked down like Fort Knox), I see no reason why you shouldn't use that same service as-is for an internal WinForms application (using a LAN/VPN to access the service layer on the DB server). For a WinForms application that must access the data over the Internet, I would recommend reimplementing the service as a WCF service supporting secure encrypted data transfer. You can also set up the service endpoint to only accept HTTPS connections, and thus simply run your existing service through SSL/TLS.
What you choose will primarily depend on how much time-resources you can commit to resolving the problem; moving to HTTPS is a fast fix requiring little if any code changes, while reimplementing in WCF will take more time but will allow additional security measures beyond a simple secure tunnel.
Or something lightweight like Nancy: http://nancyfx.org/
We had some issues with MVC4 WebApi stuff and ended up using ServiceStack on the server side JavaScript/AJAX for web clients and RestSharp for thick clients.
One of our specific issues was the inability to auto generate documentation, significant performance differences, and better support for unit/integration testing.
Rather than advocate specifically WCF, I'd recommend WCF Data Services or OData, with the stipulation that you'll need to secure it. If you go for pure WCF, you'll see that you'll end up creating a lot of code to handle retrieving the info from a database, and then sending that information right back out to your clients. It doesn't sound that bad, at first, but after about 30 entities in a database, you'll quickly grow tired of a pure WCF solution.
OData is great, it uses Entity Framework, and it quickly opens data manipulation for an existing database or one you are going to make. It will save you a ton of development time, if you can make your service secure. The format of the data response is flexible. There are plenty of client libraries ported for other programming languages as well.
The steps for securing a service are pretty simple. Always deploy to https. Any login or registration methods , need to be post methods, that return a token (Encrypted value), or a unique secret that can be encrypted and sent back for any subsequent requests. It's better to use the token, and have an expiration on the token.. because otherwise both your service and your app whether mobile or desktop, need to have a shared encryption / decryption method.
I want to send data from my Windows form to client wep page(.aspx).Pls help me.
You could use Web Services within your ASP .NET application and consume them them from your WinForms app.
Give a look to these articles:
Web Services with ASP.NET
Using ASP.NET Web Services
Walkthrough: Calling XML Web Services from Windows Forms
I would say use httpwebrequest and httpwebresponse to do this. it will be easy to do also.check the link below
http://www.codeproject.com/KB/IP/httpwebrequest_response.aspx
You can use .NET Remoting for doing this. Your desktop app can act as a remoting server, whereas your web app will be the remoting client.
The marshalled object exposed by your server (Windows app) will be accessed by the web application, which will call a method for getting the data. Your windows app will provide the data as a serializable object to your web application, which it will deserialize and process.
ther are several ways,
1) If you want to send data from window app to Web App then Use Query String.
2) If you want to send data from Web App to Windows app then you can User Either Remoting or Webservice.
3) You can user Biztalk Server for Integration.(this would be quite expensive).
4) You can build your own messaging mechanism, write all you information into a file and ask you application to read the file.