Please understand, that I am new to microsoft shop development….
I am using silverlight / c# to design a portable web-based UI (I’ll call it ‘WebUI’), that must be able to connect remotely to multiple instances of the same class (let’s call it ‘RemoteClass’), get the ‘status’ each instance and call instance methods selectively.
The idea is that the user will instantiate all RemoteClass instances manually, and will use the WebUI to interact with them if he needs to travel to another location.
I am not restricted in how I code the WebUI, however, I am working within a restricted framework when it comes to RemoteClass. RemoteClass is .NET3.5 c# only.
The relevant restrictions are as follows:
- A ‘RemoteClass’ instance, cannot see any external class instances.
- Therefore, anything I want to reference must be declared within RemoteClass.
- Any other classes I want to instantiate must be instantiated as nested classes within a RemoteClass instance
Now – there may be an arbitrary number of RemoteClass instances, each with their own unique ID. I cannot host an array of instance IDs externally, as the situation stands, and it is not possible to predict these IDs before the WebUI application is started.
Because – as it seems to me – I will need a unique URI for each RemoteClass service-instance, in order to be able to remotely call methods of one specific instance, and yet the client within WebUI will need to know the each URI in order to connect to it, the only obvious solution I can see, is to do the following:
- Write a separate ‘intermediary’ application (say ‘InterApp’), that can hold a dynamic array of IDs and instantiate 2 ServiceHost instances – say ServiceHost1 and ServiceHost2
- Require that ‘InterApp’ is running before any RemoteClass instances are created.
- Connect to ServiceHost1 upon creation of each new RemoteClass instance, and pass the ID to the array in InterApp for storage.
- Instantiate, also, a nested ServiceHost instance upon each RemoteClass instantiation, with a unique URI, based on it’s unique ID (which is know known by InterApp), which I can then connect to using WebUI by calling a ‘GetIDList()’ service from InterApp’s ServiceHost2
I hope the above makes sense – I am sure there must be a less complex, more reliable way to achieve this, though I’m still very green and unaware of the possible options….
I am intending to use a ServiceHost based server, and ChannelFactory based client…
Any advice / constructive criticism is welcome.
J
Your problem is addressed by WCF Durable Services. This supports unique service instances that have a lifetime longer than what a session allows without all the custom addressing. Its most often used with Workflow services, but it works fine on a plain WCF service implementation.