How to call windows service methods from web application - c#

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

Related

Is it possible to call windows service or process from Web Application?

I want to call my custom windows service running on particular client machine from my Web application on button click. How can I do this?
I got the solution and it works. Please find below steps.
Created Self-Hosted WCF service that call window services/processes
Call this WCF service from your web application
Please find below link for more details:
https://techinqueincsharp.blogspot.com/2019/05/open-clients-machine-local-file-from.html

execute an action in a .NET MVC Web App from a Windows Service

I have a .NET MVC web app and a Windows Service running on the same machine. Both projects use the same database through a different Data Access Layer project.
I need the Windows Service to perform some actions on the database, and i know there are different options, just want to know which is the correct:
1.- Calling an Action on the .NET MVC web app that also performs the same actions needed by the Windows Service. To do so i would call the Action with a standard "HttpWebRequest" call.
2.- Creating a Web API controller on the .NET MVC web app and calling it from the Windows Service using the WebApi.Client library.
3.- Creating a new WCF project to create a new service and calling it from the Windows Service.
I'm not familiar with any of the options above, so please feel free to post the correct way to do it.
How about creating a class library with the code you want to run and use it in both the web app and the service? I call that option 4.

Which application is better to develop for the following requirement

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.

web service event

I want to develop a web service that handle another web service's event. (C#.Net 3.5 framework)
I will develop a web service and the correspond service's event catch this service, and it will send some data to me.
Is it possible?
Thanks.
I am not sure what you meant but you can create two web services with one webservice references another one.

Send Data from aspx to C# windows app

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.

Categories