Anyone have a pointer to a C# configuration class that a .NET service can use to do configurations via an admin socket or other control port? I'd rather do this than a filewatcher on the app.config file.
We have some long running C#/.NET services (24h X 6.5 days/week) that may need to be re-configured on the fly. I'm looking for a good way to push out config changes to a .NET service
Any pointers appreciated.
Craig
How about exposing a WCF service for configuration purposes? That way you can get a nicely typed API for configuration of the service.
To expand on Manga's answer;
I'd recommend hosting a WCF endpoint on the same IIS box hosting your long running C#/.NET services. This endpoint run on an arbitrary port.
Its responsiblity would simply be to change the appconfig(s) of your running service(s). You could specify a config type decorated with DataContract to allow for a nice configuration API exposed to the client responsible for pushing the config changes.
I'm not experienced with WCF, but I've typically solved this problem by rolling my own API via RPC. Expose some methods to add/remove/update certain configuration items, throw some sort of UI on top of it, and you can update your service on the fly.
Related
I've recently discovered Azure Relay and it seems very powerful. I have a basic project using it now to expose a WCF Windows Service. I've read in the documentation about how it can be used to expose RESTful services, but I'm having trouble understanding if it can be used to expose a SOAP web service. I can't seem to find any examples of that and the closest I can is this post about exposing the WSDL. I have an extremely simple SOAP web service with a single method that takes in 5 strings as arguments. I know WCF Services can be hosted in IIS but my client's requirement is that no firewall ports are opened so here's my actual question:
Is there a way to use a Relay to expose an internal IIS WebService publicly? Is there another method I might have overlooked to get around opening a port in the firewall?
I would be very open to exposing the service I have or rewriting it completely since it's so simple, I'm just not sure what my options are.
You could try to re-implement the service as RESTful service or as a Web API and then use Azure's API Management to expose it to the outer world.
Hope it helps!
I created WCF service and faced with a problem. I need to update database periodically, but i couldn't find static method like Main, that whould do it without client interaction. What can i do??? What wold you suggest in such case?
There is no Main method (or similar entry point) in WCF. You need to host your WCF service in another process (such as a Windows service, or IIS or self host) to "activate" it and make it available to other processes.
One of the concepts in WCF is that you write your service code to do the function you need without having to worry about infrastructure and hosting. Once you have written your service logic, you can then decorate and configure your service to expose it to other processes. Using this approach means you can change how your service is exposed to other processes without re-writing the actual service logic - you essentially just change your configuration. Hence, a main entry point is specific to how you choose to host and expose your WCF service to the outside world.
Just Google around for "WCF hosting" and you will find lots of information.
If you don't need to expose your service logic to an external process (which sounds like maybe the case from your question) then maybe you don't need to use WCF and you can just write a plain old Windows Service.
If your wcf service is self hosted then you can do it in your application before publishing the service.
If it is in IIS then there really isn't application_start kind of thing since the host may be created on first request. See WCF application start event
I am trying to build a service mechanism which should be add-on based and communicating through a publish subscribe system. It must be based on WCF services.
What I have right now is a concept which I can't get to work so I decided to ask you because maybe I am going at this the wrong way (I only just started using WCF).
What I want to achieve is making a single core service with session persistency which can be extended by linking an unknown number of add-on services. I want to set up the publish subscribe system at runtime, not at buildtime, so the core-service should be able to detect what add-on services are available (using the web.config?) and then bind them to the message bus.
From the front end (ASP classic) it must be possible to access any .svc file but, maintaining session, each .svc file must be connected to the message bus.
All is hosted in a single IIS active directory.
Can you give me some hints as to where to look?
I am especially interesed in:
WCF dynamic discovery
WCF to WCF communication on the same host (in the same active directory even)
Thanks in advance, hope you can help!
Update
Thanks for your answers, I'll read up at the links you send me. I'll post my final concept solution here in due time for future reference.
My 2 cents about Publish subscribe mechanism using WCF - WCF is not inherently built for pub/sub mechanism. It is built for Request/Response model of communication. Have a look at the NService Bus for pub/sub here
Talking about Add on services on top of core service, I am not able to get What you want exactly ? Is it the Routing service which you want ? WCF 4 now provides routing service For more information look here The link also talks in detail about the discovery mechanism in WCF 4.
Also have a look the Agatha framework which also have single WCF service and no. of request handlers where in the framework will decide which request handler to call based on each request.
Search for Agatha - Davy brion for more information
I was having a similar problem since I have one common WCF service but the implementation depends on the user's role so it was kind of difficult to do that at runtime.
I found this tutorial on the matter which runs great for my propouses: http://blog.micic.ch/net/dynamic-iis-hosted-wcf-service
I have tested in my env and is very powerful technique. Hope that helps you as well. Cheers.
I have an application that is built as a Windows Service and a c# library assembly (.dll.) In order to manage and maintain this service, I'd like to add the ability to run a command-line application that tells the last time the service archived files, the next time it's scheduled to do so, the status of the last run, and the location of a file created by the service.
What's the best architecture for writing a service and library that can share data with another application? I'm using .net 2.0.
The way that inter-process communication happens in .net is through remoting (even if both processes are on the same machine). Other responses have suggested alternatives to inter-process communication which would not require remoting.
The best architecture is probably to make your service be a "server" that can report on it's status (and whatever information you want). Using WCF for this like ocdecio suggested would make it pretty simple.
I use WCF for that and create a contract definition for the commands/events I want to support.
Options that spring to mind that I've applied in the past:
Save the information to a database
(if you have one to hand)
Implement a
"status monitor" type thread on the
service that the client can connect
to and query via TCP/IP etc.
A fairly simple approach is to store that information in either a local config / text file which both apps have access to. Or even to place it in a registry key.
+1 for just having the service provide that (and any other data) when it is queried (simple tcp, RPC, web service, or whatever)
I'd make it pretty generic - like
QueryInfo(some identifier)
with a response as some string and a return value or other indicator that the service does not know what you are talking about, cannot get the info, or give back the info
I'm taking a Masters capstone course early and doing my project in C# while everyone else is doing theirs in Java. The project has 4 services and requires a name server that maps service names to sockets. The instructor is suggesting that the students use RMI to build this registry. Since I'm not very familiar with Java, and the instructor is not very familiar with .NET, we weren't able to come up with an equivalent in C#. Anyone out there aware of one?
Update:
I'm looking for a way to discover a WCF service without explicitly knowing its socket.
Update 2:
I will be demoing the project on my XP laptop using VS 2008/WebDev server.
You can use the UDDI server that comes with Windows Server 2K3/8. This will give you discovery of your services. Other than that you would need a 3rd party package or roll your own.
RMI Registery in java works as a container where you can lookup services by a key. This mechanism is similar to resolving services/objects via ServiceLocator (e.g. ServiceLocator pattern) where you use a dependency injection engine, and ask it to resolve an instance of the service (i.e. by a known name, by interface, etc.):
IMyService service = ServiceLocator.Resolve<IMyService>();
or
IMyService service = (IMyService)ServiceLocator.Resolve(typeof(IMyservice));
WCF works only in a single service vs. single service host fashion, meaning each single service requires a separate service host. You can write a service container that aggregates the service hosts, opens the port, and registers them in DI container, and later simply ask for an instance of the service as mentioned above.
I am no expert on Java Remoting.
I think what you are looking for is called in WCF terms Service Endpoint.
This can be done either in a config file or via code .
For an overview on WCF I would refer you to this link:Windows Communication Foundation Architecture
Read about TCP Port Sharing, new technology in Windows Server 2008, it could helps you