I have a Windows Service which performs some data collection from a serial device connected to my PC. This Windows Service hosts a WCF service over named pipes which can then be used my one of my applications in order to query the serial data.
The problem is that I want to send log messages from the service to the application sometimes - for example I would like to send a log message to the application every time a certain value is received over the serial connection.
The WCF over named pipes is working really well for pulling service information from the application, but what I want to do is push some values from the service to the application every now and again in addition.
Any ideas?
AK
We solved this problem recently.
Our solution can be find at flexbit.at (German) with a downloadable sample project.
For further info you may contact Daniel - he solved this.
Related
I have created a WCF SOAP web service in C# and a C# application. Other users will work with the application and are trying to get information from a local database via the web service.
Now is it possible that the web service can go down. Then I want as quickly as possible, let's say getting an email.
I can let the application which is by the users sending an email when they don't get a connection with the web service, but there are more than 10.000 users. And I don't want to get 500 emails when there are 500 online.
Is there a better solution for getting an email when my web service is down?
I would suggest a sort of heartbeat program that runs on another server / location.
This will not only test the server, but also your internet connection for example;
Will work even when the power is down.
There are programs to do this already. The only I know is Microsoft System Center and Nagios.
There are a lot of monitoring software packages out there if you want a pre-made tool. The company I work for uses New Relic. (http://newrelic.com/server-monitoring).
If you add a simple function to your webservice, that simply returns true, you can call it periodically (maybe every minute?). If it times out, your service is down, and your monitoring program can email you.
I manage a web site for company that hired me after being unsatisfied with the original developer of the site. One function of this site is to add new patients. Part of adding the patient is to receive data from a USB port on the client machine via an applet. Since the Java 7 update 21 the applet does not work and the company has asked to remove the applet and replace it with a different solution. I am having trouble doing this, however, due to the applet listening to the client USB ports from the server to retrieve the data. I Have thought of a few ideas to solve this but am unsure if it is possible and haven't been able to find the answer online. I was hoping someone here could tell me if my idea is possible or point me in the right direction.
When the user adds a new patient the web site will call a web service on the server. This web service will then call a WCF hosted Windows Service on the client and active its serial port listener. Once the client's Windows Service has received the data the WCF will respond to the Web Service on the server and parse the data.
What I'm having trouble with is finding a way that the web service can call the WCF downloaded by the client and have it begin listening to the USB ports. If anyone could tell me how to do this, or suggest a better way to have the server initiate the client listening to the serial port I would appreciate it.
Do you have any system requirements?
When entering new patient, what kind of browsers are expected?
Will this be deployed as one solution, or clients expect that your application
can support any modern browser?
The main problem is that browsers are very restrictive in terms of what
kind of code you are allowed to execute. By default, browser won't allow
to execute any plugins / read any usb ports, let alone execution / installation
of arbitrary wcf service.
So, supposing that you have 'any modern browser' in requirements - you have following options:
Java / activex applet plugin. I believe this is the only sure-way to have access to usb
on a client machine. Also plugin must be signed with trusted certificate, or client must allow
execution of untrusted plugin (again, check requirements). I though silverlight would also
be a valid alternative, but according to my research (please correct if I am wrong) - its security
model does not allow any kind of USB access.
Prompt user to download and install browser plugin / helper object with access to usb.
And then communicate with your web page through this plugin.
Installing an entire wcf service on a client side would be an overkill in my opinion.
You would have to manage issues like firewalls, closed ports, security,
writing a self-hosting wcf solution, etc.
But if you managed to install and host a wcf service on a client side:
When the user adds a new patient the web site will call a web service on the server.
This web service will then call a WCF hosted Windows Service on the client and active its serial port listener.
Why not save a roundtrip and call client service directly from page?
Server would need to know client address to call it, which is not always possible.
Probably your web page can attempt to access localhost, at predefined port,
where your wcf service is listening.
Once the client's Windows Service has received the data the WCF
will respond to the Web Service on the server and parse the data.
It would be easier to respond on call from your web page (use polling if usb reading is slow),
and only then send to server. Browser already knows where to send data, and have permission
to do so. But if your server address is well known and can be accessed with domain name,
you can try to connect to it from your wcf on client.
Also there is a very similar topic, discussing connection to usb from client.
I am creating a client application that downloads and displays market data from Yahoo! for a university project, but that also sends out notifications to mobiles (so far using Google cloud messaging). So far it's a WPF client and the "server" is a class library - so far working. What I was wondering, is can you mix this server with a WCF service - the WCF service I was planning on using for registering devices, as well as accepting and parsing commands.
So I would call .Start() on my server object, and it will be constantly running in the background, while a WCF REST service runs alongside it - or would I be better simply having a thread running on the server that can accept input... sorry if this is confusing, but just wondering if it can, or has been done before or any advice. :)
Just to explain a bit better
The client front end and the "server" are running on the same machine - I was calling it a server because it is not only updating the front end, but sending out GCM notifications at the same time. I was wondering if maybe a WCF service could be added to make it simpler to handle adding devices to a database ("server" reads a list of device reg ids from a database, sends notifications to these) by allowing an android app to details via REST or something similiar
I would explore wrapping the class library in a Windows Service (which is essentially a process that runs continuously, and can be stopped/started/paused) and keep your WCF service as a web service for client communication.
How the WCF client service communicates with the Windows service is up to you - whether you store the data in a shared database, keep it in memory and have another WCF layer communicating between the two, etc. A shared database would be the most straightforward, especially if you want to persist the data for use by other apps/services as well.
WCF Service would be useful if you had one notification service on your server with multiple WPF client application connecting to it. If you have just one application running on the same server then not sure if it will be worth the overhead.
The usual pattern is to host WCF service in IIS, that way it always starts whenever first request is received. WCF is very flexible though, therefore you can host in in Windows Service, Console Application, etc.
Our desktop application require to be updated directly when a mobile employee sends any message from his/her windows phone 7 mobile.
Currently our requirement is that send a message from our desktop application to a Windows Phone 7.5 which we are able to achive easily using PUSH Notifications, Now when the user takes some action against the sent message the windows phone app calls the WCF service and pass the message to that WCF which receives the message and puts into the database and application reads it later and this is where problem lies. Because our WCF is putting that message into database our application is polling it every 5 second and if any replies received from any of our drivers then it is updating the UI.
What we want to achieve is when we receive any reply our desktop applicaton should be notified automatically and udpates the UI and then put it into the database.
So please share your experience on this issue.
Thanks
Why not update the WCF service to notify any registered "listeners" (i.e. running instances of your client app) that the database has been updated with new information?
You could do this by having your service expose a service that can be called by clients wanting to register for some/all event types. The client app(s) host a service implementing a callback contract that the service can call when the registered events are raised.
There's a good MSDN article one-way, callback and pub-sub messaging with WCF: http://msdn.microsoft.com/en-us/magazine/cc163537.aspx.
Be sure to keep track of and throttle how many events your client app is receiving per second - the last thing you want to have happen is for 100 client apps to all hit the server 50 times each if 50 events are raised sumultaneously!
Richard's solution is probably more proper, since it describes using nicely packaged WCF APIs that will do a lot for you. Another way could be to implement long-polling yourself. You could then also update your Windows Phone clients when they need to receive an immediate update. I wrote an article on that some time ago which you can find if you google long polling on Windows Phone.
I'd like to write a program where you can have 2 clients that talk to each other in realtime. I've been looking into WCF services and Duplex messaging, data contracts etc but now I'm confused.
Basically I see it as:
[Client] --- msg --> [Server] --- msg --> [Client] and vica versa.
The server will just act as the messenger.
Could you please point me in the right direction? I'd like to use WPF for the client apps.
Check out the WCF peer-to-peer programming paradigm. It will be extended in WCF 4 (with .NET 4 - due out April 12, 2010) by allowing dynamic discovery (and article here) of other clients on your network.
This should help get you going: WCF / WPF Chat Application
Perhaps Windows Azure Service Bus (which uses WCF) might be worth a look?
Service bus can effectively be used as a message bus, which is one way to implement what you are describing.
I can think of two scenarios
The clients are the only ones that start a request, to send they push messages and to receive they request periodically for new messages. The main advantage of this architecture is that it is more firewall-proof.
The clients are also servers that receive messages relayed by the central server. The main advantage is that the clients receive updates faster and they save bandwidth.
I wrote program like your sample!!!
but it has one big different: My program have a chat server and a client. clients can chat to others.(with chat server service)
This program use two wcf service for make a connection between client and server.(client call server and send message for it,server get message from client and send for all client have connected to server)I think u used one service and must be use two service(like me) or use Duplex Service.
The sucha barber`s example is too cool(WCF/WPF Chat Application in answer eric). He used duplex services but real problem of this example is "sucah used WPF too and it s expert example for beginners (like me and u)".
If u want i can share my program!!!
seethis