How can we access windows service in webapplication using dot net - asp.net

I need to read the data from the COM port in a web application, so I have written a Windows Service for reading data from serial ports. Now I need to access that data in a web application. Can anyone tell me how to access it? Is using threads the best way to do this or not? What other possible ways are there?
upendra

Get your Windows Service app to store the data to disk (xml or SDF for example). Your Web application could then access the same data store...

An idea would be to use an .Net Queue to read the values from. Read more here: http://msdn.microsoft.com/en-us/library/system.collections.queue(v=vs.71).aspx
Your other options would be to write the data to a file or a DB but then you have to write your own logic to handle disposing of read data which the Queue functionality will take care for you.
Cheers,
Stefan

In similar scenario I used self-hosted WCF service within windows service. In this way you expose api to control the service and get information from it.
You can read more about WCF self-hosting in Michele Leroux's article : link

Related

Securing a database using web service

I have a SharePoint application that needs to integrate with very sensitive databases. The data required is from multiple databases; almost 40 different databases on different servers.
The suggested design was to have a web service to integrate with, which will then connect to the required database based on the required business logic. However the concern is, if someone somehow got access to the server hosting this web service, all the database connections will be there.
Another suggestion was to have a dedicated web service for each database. This way even if someone got access to this web service, only one database connection will be there.
The question is, is there any known design that can work for this situation to add more security to the database connections?
The answer really depending on your specific requirements. an easy way of doing so is to use "Open Data Protocol" OData. and then secure it with windows directory login, or perhaps ASP.NET login.
take a look at http://www.odata.org/ and http://msdn.microsoft.com/en-us/library/ff478141.aspx

Subscribing to Web Application Events from WCF

I have a simple web application that allows users to upload a file to the server and store the data in the Database.
There will be a decoupled service (probably WCF) which needs to act upon the data, but i am not sure what the best mechanism is to alert the service? Is it a good idea for the WCF service to poll the database every few minutes to check for new data? Or should i be looking at other patterns (?) to better accomplish this task? using Events perhaps?
I have not done anything like this before so looking for some guidance to start off with.
Thanks
Why don't you want to call the service from the web application in the same code that performs the upload? Typically, an application calls a service, not the other way around.
Polling from client side is an option. Or you can have a non duplex service for file upload and have a duplex service for callback on the progress of the upload.
Also Take a look this sample which uses non duplex channels to track file upload and download.

Send and Receive data to Web Server

What is a good way to Send data to a web server and then receive and port the data to a Microsoft Access database on the web server?
Sounds like you need some tutorials. Here's one.
http://www.devtoolshed.com/content/building-web-service-aspnet-35
Note that there are MANY different ways to create a web service and consume it.
Examples include: Generic Handlers (.ashx), MS Web Services (.asmx), WCF services (.svc), etc.
All of them have features / benefits. Probably the easiest one by far is to use generic handlers which are great for building RESTful type services.

How to design a WCF service which can support 10,000 simultaneous hits

I am a beginner in WCF and want to take some help in creating a WCF for my project.
I have to create a WCF service which can support 10,000 users simultaneous hits.
The job of the WCF service is to fetch a cached up XML object (we are using Enterprise Lib caching) and return it to the caller.
This WCF service will have to be publicly exposed. So I was thinking that we may have to use basicHttpBinding... I don't know, I may be wrong.
Can anyone please suggest the best way of going ahead with this?
Thanks a lot!
Don't use reliable messaging
Don't use sessions
Don't use transactions
Don't use Duplex
Don't use message security
Use BasicHttpBinding or NetTcpBinding
if you need security on HTTP, use HTTPS (TCP already implements encryption)
My personal view, don't use WCF if you need performance! :) Use ASP NET MVC with JSON message format and if you need security, use HTTPS.
This article might be useful - http://mikehadlow.blogspot.com/2011/03/7000-concurrent-connections-with.html

Web Database or SOAP?

We’ve got a back office CRM application that exposes some of the data in a public ASP.NET site. Currently the ASP.NET site sits on top of a separate cut down version of the back office database (we call this the web database). Daily synchronisation routines keep the databases up-to-date (hosted in the back office). The problem is that the synchronisation logic is very complex and time consuming to change. I was wondering whether using a SOAP service could simply things? The ASP.NET web pages would call the SOAP service which in tern would do the database calls. There would be no need for a separate web database or synchronisation routines. My main concern with the SOAP approach is security because the SOAP service would be exposed to the internet.
Should we stick with our current architecture? Or would the SOAP approach be an improvement?
The short answer is yes, web service calls would be better and would remove the need for synchronization.
The long answer is that you need to understand the technology available for you in terms of web services. I would highly recommend looking into WCF which will allow you to do exactly what you want to do and also you will be able to only expose your services to the ASP.NET web server and not to the entire internet.
There would be no security problem. Simply use one of the secure bindings, like wsHttpBinding.
I'd look at making the web database build process more maintainable
Since security is obviously a concern, this means you need to add logic to limit the types of data & requests and that logic has to live SOMEWHERE.

Resources