How to communicate between two applications? - wcf

I have created a library which reads the app.config file and gets the type of WCF service in which it is called.
Now, I have a separate console application, I want that this library informs the console application about the type it found in the WCF service so that the console application can host it.
It is useful because then I will just add my library in any WCF service and call its method and it will then inform my console application and it will host it.
Please give me an idea on this problem.

I have to agree with Marc, but this is perhaps related to your question regarding ServiceHost, but what is the purpose of your console application?
Is it acting as a host or as client (consumer of the services). If its a host I would simply add the appropraite configuration in the app.config?
HTH
Phil'

Related

Deploying WCF Library

I am sorry in advance for the question because it should be so easy for someone who has web programming experience, but for me ...
I have created a WCF library which gets an email address, subject and body and sends email using a gmail account. I do not know how I can deploy it.
I already published it on my host using visual studio but don't know what URL should I use to call it. Can I use it directly or I have to create a WCFapplication and add the service to it then publish the WCF app?
Also, I noticed the base address in its config file is sth like: localhost/emailservice/service1 and I am not sure if I should edit it or not and how.
Your help is greatly appreciated.
Since you created a WCF library, I am assuming that you are open to host it as an IIS application or as a windows service.
Assuming that you wish to host your library as an IIS application, follow the steps mentioned in this blog to host your WCF service library.
Please note: If you intended to host your service as an IIS application, it would have been far easier for you to create a WCF service application project in Visual Studio instead of a WCF service library project.

How do use WCF to communicate between an Application and a Windows Service?

I've gone through some tutorials on creating a WCF service. I'm using Visual Studio 2012. I got a very simple WCF Service Library (vb.net) and Windows Application (vb.net) communicating via WCF. That's a start.
However, my project requires I do the following:
My Windows Service - This is already an application that has it's tasks.
My Application - This is an application that is already developed as well.
I need the service to talk to the application. The service will need to send the following information to the windows application:
Status Updates
Metric Information (mostly integers for counts)
I need the application to send information to the service. It would need to send:
Reload Configuration command
Should be relatively simple, but I've never worked with WCF until today. So I have some questions...
Do I need to re-work my current windows service into a WCF Service?
Since it won't be in IIS, do I also create a WCF Service Library or do I roll this into the windows service somehow?
What is the best way to set up the different types of communication? (i.e., sending over specific metrics and reload commands)
Probably the main question is what components, in addition to my current windows service and application, will I need to make this work?
I hope that was clear :( I think I'm confusing it all... but I hope not
Your Windows service can host the WCF service. Similarly, if you want, your application can host a WCF service. The application could talk to the WCF service in the Windows Service, and the Windows Service's WCF could talk to the one in the application. Depending on the nature of the communication, you could also just use a callback channel to permit the Windows Service's WCF to call back to the application.
I suppose you should configure your WCF windows service to use named pipes. If your windows service is already built then the easiest way to do it would be to build another one as a WCF windows service and wrap the already existing functionality.
Hope I helped!

Questions about adding a WCF service to a Windows service assembly

I have found some basic information about hosting a WCF service in a Windows service, but not much. All of my experience thus far with WCF has been in Web projects. I have a few simple questions.
I have a project which creates a windows service application. I have done a right click -> add WCF Service. This creates Service1.cs and IService1.cs.
I'm wondering why no SVC file is created in this scenario? When I add services to Web projects i get an SVC file which I can navigate to and use to consume the service.
Adding the service adds some configurations to the app.config under the services element. I'm seeing a default base address of
http://localhost:8732/Design_Time_Addresses/WindowsServiceName.services/WCFServiceName/
What does this mean? It's sort of an odd looking address. Am I supposed to change it to whatever I want?
Navigating to this address in a browser results in an unable to connect message. Does the windows service itself have to be running to talk to the WCF service?
How do I go about consuming this service from another application without an svc file?
I'm taking a guess on this first one, but I'm thinking the .svc file when hosting in IIS is to tell IIS, "Hey I have a WCF service here, please handle accordingly".
The base address is as it should be and yes you can change it if I'm not mistaken.
You can't hit the WCF service unless the Windows service is running, which is one of the dangers of hosting in a Windows service, because if the service dies somehow your WCF service is offline until you get the Windows service running again.
You consume the service the same way you do any other WCF service, just using that base address to get at it.

How to call local WCF service from webpage?

I'm developing a webpage that is supposed to consume WCF webserice that is located on client's computer. First, user installs some software that hosts WCF service on his computer, then he'll view my webpage which is supposed to call the WCF service. Do you have any idea how to do it without having to use AtiveX and IE?
Add your wcf service as service reference to your web project. You have to specify the url of your wcf service. A clientproxyclass will be generated for you. In your webpages or whathever you can create a instance of this proxyclass and just code what you want.

What is the difference between a WCF Service Application and a WCF Service Library?

I am developing a WCF web service and I used the WCF Service Application template to do that.
Does creating a "WCF Service Application" fulfill this requirement?
What are the advantage of creating a WCF Service Library over a WCF Service Application?
A service application includes a website host already setup for you. A service library is a library of services that a host can reference and startup.
If you start with a service library (recommended) you can then choose any host you wish (a windows service, IIS/ASP.NET, or even a console application) and you'd just reference your library from your new host. Choosing a Service Application limits your host to just IIS/ASP.NET (though this might be ok for your purposes, but will limit the protocols you can use).
Edit: Changes in IIS since I wrote this allow for a wider variety of protocols on ASP.NET activated services, so choosing a service application is much less limiting than before.
If all you have is the one project I see only added complexity if you separate for the heck of it. I used a library when I had some particular use cases where I had to host in both a windows service and in IIS.
For IIS you you can move the classes and interfaces to a library but keep your .SVC files in the web project. You must edit the .SVC files to point to the properly qualified classes.