views:

52

answers:

3

Hello,

I have a generic service which i can host in an exe and call from another .net app, but since web services on IIS are loaded on demand, i cant host it an web project.

is there a way to tweak the wcf stack to read the url ( in which i can pass the type information) and invoke the service ?

i tried using servicefactory, but its more for injecting behaviors rather than invoking a service.

thanks

A: 

This seems to fit on serverfault.com?

Dean J
A: 

I'm not sure what you mean...

I'll assume that what you want is to use some mechanism to create an instance for the service on demand based on the url. For example, calling http://localhost/Service1 would instantiate Service1, http://localhost/Service2 would instantiate Service2, etc... Without having to create all these virtual directories.

I never did this, but it should be possible to do using URL Routing in ASP.NET. For the how, you will probably have to test :)

Philippe
what i have is a service like public class MyGenericService<T>:ServiceBase{ ....}i can host it in a exe and call it from another app, but cant host it in IIS using .svc, since its on demand and Type T is not known.so there would be a separate instance of this service for each Type T.is there any way in wcf to read the url and invoke the service with correct type T ? i can modify the url on the client side to indicate the Type T
+1  A: 

OOP (including things like generics and interfaces) and the SOA (Service oriented architecture) world don't almost match up entirely.

This might be one of those cases. The WCF system is geared towards sending messages between client and server, and thus, it's always about real and concrete implementations; WCF messaging doesn't handle interface, and as far as I've experienced, it doesn't handle generics all that well either.

This is especially true if you consider the interoperable nature of WCF - it's after all NOT "just" a .NET technology, but an interoperable SOAP (and REST) stack that could be talking to other systems that have no clue about generics (yes, those still exist).

Anything you want to send back and forth between client and server as a SOAP message has to be in a form that can be expressed with a XML schema (your DataContract) - I don't see how you want to model a generic MyType<T> in XSD - it's just not designed to do that.

So as much as I like generics, too - I don't think they're a good fit to a service-oriented scenario. So I guess you'll have to redesign your services a bit to take that into account.

Marc

marc_s