I have a WCF Rest web service that I am hosting in a managed application. What I would like is for client input to the service to be passed to the host application for processing, and the results are then passed back to the client. From similar questions like here and here I know I can use events to pass the data from the service to my host application. However, I cannot seem to figure out how to get the resulting data passed back to the client. Is there a way to do this using the webOperationContext or perhaps by creating another event in the host application to pass the data back to the web service?
Related
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.
I want to control application (in my case it is corelDraw) ,I know I should use it's application object and I do this, but the issue now is I want to do this in webservice,
so as far as I understand if I put this code which control the application in the web-service ,my code will try to control the corel application which is on the server not on the client :(
so any hint/advice how could I do this, and control the application on the client not server ?!!!
As you already noticed web service runs on server and only result is passed to client.
Well you have a few options to control client machine over web service... Here is one of possible scenarios.
1. create web service that will provide commands for client
2. create windows service (client) that will consume your web service commands
3. inside windows service then just execute those commands in appropriate manner
Well I have to say this is not the prefered way I would take to automate corelDraw, but if you insist on using webservice as command provider it will do the job.
You need to ask yourself what is the difference between client and a server. Can a client be a server? Can a server be a client?
You make your client with CorelDraw installed to accept web-service request, i.e. effectively make it a web-service server, and then carry on as normal.
Although I would say web-service is not the best way to control such complex application as CorelDraw. I'd look in some other ways of communication between peers, like lower level network communication that would not have overhead of HTTP.
I have a WCF service lib which run by a self-host [Winform] and a client [Winform], and im using NetTcpBinding.
i want the client to call a method from WCF service to Pop up a MessageBox on Self-host Winform.
the point: i want to send an image to the server side, and it should appears in a new form, but i can't communicate between WCF service library and its Self-Host Form.
please can you help with an example that shows me how would i show a messageBox on Self-host winform when a client call a method from WCF service lib.
You could create your service as a singleton and pass in the Form in its constructor. Then pass this service object into the ServiceBase.
Then when you get a function call you will have reference to the Form and can manipulate it in that fashion. Be aware of threading restriction on working with Form applications.
You can return a success or failure message from the service call which sends the image to the server side. Assuming that you were successful in sending the message to server, you can open a new form and populate the message box or whatever user interface control you wish o display to the user. As I mentioned in the comment, the service colud be multitenanted and you should not mix user interface relatd code in service layer.
We are using WCF Services that transfer some data from a Client Application to the Server Application (WCF Service). This last one will apply an algorithm using these data and send back the result to the client.
We would like to authenticate the Client Application from the Server WCF Service. Would it be possible to get the Client Application Checksum directly from the WCF Service?
We are already using wsHttpBinding but we would like to add one more layer on the client application integrity.
Appreciate for your help,
Camille.
he WCF service can't get anything from the client unless the client sends it to the service. So if you can get your client to send your service the checksum (as a method parameter), then you're in business. WCF is not magic. Nor is any "service" technology for that matter. It is a simple tcp/ip communication between a client and a server. On both side, the only information that goes across is the information each side decides to send, nothing more.
I using two WCF services. WCF service A is hosted in my .NET Winform application and WCF Service B is hosted on a Windows Service.
I am able to instantiate a client for WCF Service B and use the methods - i.e. call the WCF service hosted on Windows service from the .NET Winform app.
I am not able to accomplish the reverse with WCF Service A - i.e. call the WCF Service hosted on the .NET Winform application from the Windows Service. The call to the method times out.
I have used the WCF Test client from the Visual Studio command prompt and it can successfully make calls to WCF Service A.
Is this due to a security issue or something from the Windows Service?
Please advise.
Thanks in advance!
Subbu
I think the only viable approach (without the extreme of having some messaging infrastructure), is to have the service invoke operations back on your client via a WCF callback. A good example of this can be found here:
What steps do I need to take to use WCF Callbacks?
This is good for dealing with events that happen server side and allowing the client to respond to them. If events isn't what you're looking for, then your client could just register with the server (specifying the callback contract), and then the server can invoke your client at will.