Interacting with windows service to send and receive data? - c#

I have created a service on Windows it is installed on localhost and now have to interact with this service .
Inside my web application I'll give a query command that will be sent to this service and this service will make this query on another IP and return the result to the application .
Within the OnStart method I created a StreamWriter 's fulfilling a text file , to make sure that the service is working.
How do I send requests for this service and receive his answers ?

To solve my problem I created a socket server on this basis .
https://msdn.microsoft.com/en-us/library/bew39x2a%28v=vs.110%29.aspx https://msdn.microsoft.com/en-us/library/fx6588te%28v=vs.110%29.aspx
Creating the service within the same Web page solution that will display the information sought by the service.

Related

how to connect outbound message to external web service

I'm trying to test out a simple outbound message workflow that will insert a contact record into an external database when the contact is created in Salesforce.
I've created my web service using (C#.NET) VisualStudio 2008 and have tested it successfully directly from the browser from my localhost URL. So, the web service works and inserts the values I pass into the method and insert into my database.
I've also created the workflow in my salesforce development org with the outbound message action. I'm pointing the EndPoint URL value to the localhost URL of my web service.
If I understand correctly, I need to create a listener so that when the workflow fires and sends the outbound message, my web service knows what to do. This is where I'm stumbling.
Can anyone help on how to make that connection? How do I create the listener and make the handshake between the outbound message and the web service?
Thanks for any help.
There are is a comprehensive example in Creating an Outbound Messaging Notification Service with CSharp and .Net Framework 2.0
This important parts are:
Export the outbound message WSDL and have your web service implement the interface. It will be SomethingSomething.INotificationBinding
Have your web service return an ACK on successful processing or a NACK if there is an error or exception.
Ensure your web service is exposed on a public IP address. Salesforce will need to be able to call it.
As above, add your web service to the Remote Sites so that Salesforce is allowed to call out to it.
Incidentally, salesforce.stackexchange.com is a great place to ask Salesforce specific questions.

How to control application via webservice

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.

WCF, how to self-host callback?

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.

Logging messages from Windows Service to Application via Named Pipes in WCF

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.

How to access client application from web application with service application

I would like to write a Web Application that can interact with 3D Cad program for our company. So I was thinking that I would create a program that would be locally installed on the client machines which would send and receive data back and forth from Client App to Web App. I would like to use xml for moving the data back and forth too. Does anyone suggestions or can this even be done?
In this case you need 2 way communication between app and service. and for solving that there are two way:
use two service and they must be client of each other (Hard way)
use Duplex Services. (you can use WCF-Duplex services - it's not simple)
in this case you must handle too many issue's.(take look at this)
As example:
app need to notify self on your service and service save address of active client's. so every time service want's to call one of client, service must find client's address in active-client's and then call that.
Let me know if this help you.

Categories