A new set of projects have been added (SoftwareIsHardwork.ServiceModelClient.*) to the Software Is Hardwork Library solution to support a WCF client proxy factory with operation interception pattern. This code allows a WCF service client to spin up an arbitrary instance (of type TServiceContract) of a service contract for a given endpoint configuration; the returned instance is actually a runtime transparent proxy (in the remoting sense). The proxy plumbing code inspects, intercepts and forwards client service operation calls to an internal channel of type TServiceContract. All that is required on the client is the service contact assembly and an endpoint configuration.
Why is this valuable? The ServiceModelClient.* code by default, for each discrete operation call, creates a ChannelFactory
Remoting real proxies (the source of the transparent proxies) are cached per service contact type and endpoint configuration name. The interception code is decoupled from the remoting code; the actual interception could be handled by some other package such as Castle or Spring, if one was so inclined to write an alternative IServiceClientFactory implementation and leveraging the ServiceProxy`1 code in a similar manner to the RealProxyServiceClientFactory`1 class.
(Click images for a larger view.)
Please see the solution for sample use cases; the code will be available in the v1.1 drop. This approach is quite an attractive alternative to generating proxies from WSDL/XSD + svcutil or using a raw ChannelFactory`1.
0 comments:
Post a Comment