Let's say I have a ServiceContract interface :
[ServiceContract]
public interface IHelloService {
[OperationContract]
string SayHello(string message);
}
Let's says I don't have (and don't want to have) any implementation of
IHelloService.
But I have an interceptor (let's call it HelloServiceInterceptor)
which knows how to answer the service calls.
I'd like to have my init code look like this :
container.Register(Component
.For(typeof(IHelloService))
.Interceptors(typeof(HelloServiceInterceptor)).First
.ActAs(new DefaultServiceModel()
.AddEndpoints(WcfEndpoint
.BoundTo(new BasicHttpBinding())
.At("http://localhost:6080/HelloService/")
)
)
);
Do you expect that be feasible?
How can I customize Windsor and/or WCF Integration Facility to achieve
that?
Maybe a custom ServiceModel would allow me to do the job?
Cheers,
Frédéric
--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.
You're welcome, thanks you for your time.
About the exception, I get it when trying to call the service (line " client.Hello(); " -> server actively refused connection )
I am considering providing my own customized IWcfServiceHost and/or AbstractServiceHostBuilder and/or WcfServiceModel
to support the feature (expose WCF service with only an interceptor to handle the requests).
Krzysztof,
Good news you consider adding the feature to WCF Facility.
I also already have a solution working with DP, just could'nt figure out if WCF Facility was already capable of it.
Can I help on this one?
I was considering providing my own customized IWcfServiceHost and/or AbstractServiceHostBuilder and/or WcfServiceModel
to support the feature. Or do you consider adding this to the DefaultServiceHost/HostBuilder/Model ?
Fr�d�ric
I was able to build a working proof-of-concept solution based on DynamicProxy and WCF only.
We'll take a look at bringing this functionality to WCF Facility now.
Krzysztof
On 2010-02-10 20:47, Craig Neuwirt wrote:
Definitely a limitation.ďż˝ Working with Krzysztof to find the best solution.
thanks,
ďż˝ craig
2010/2/8 Fr�d�ric Legrain <f.le...@gmail.com>
You're welcome, thanks you for your time.
About the exception, I get it when trying to call the service (line " client.Hello(); " -> server actively refused connection )
I am considering providing my own customized IWcfServiceHost and/or AbstractServiceHostBuilder and/or WcfServiceModel
to support the feature (expose WCF service with only an interceptor to handle the requests).
Cheers,
Fr�d�ric
2010/2/8 Craig Neuwirt <cneu...@gmail.com>
Thanks,
ďż˝ I'll take a look when a get a free moment.
2010/2/8 Fr�d�ric Legrain <f.le...@gmail.com>
Here it is : just copy/paste in a Console application with the required references (see usings, i'm working with trunk of WCF Integration).
Tanks,
Fr�d�ric
--------------------------------------------
using System;
using Castle.Windsor;
using Castle.Facilities.WcfIntegration;
using Castle.MicroKernel.Registration;
using System.ServiceModel.Description;
using System.ServiceModel;
using Castle.Core.Interceptor;
namespace WcfIntegration.ConsoleDemo
{
��� class Program
��� {
��� ��� static void Main(string[] args)
��� ��� {
��� ��� ��� Scenarios.InterceptorOnly.Run();
��� ��� }
��� }
}
namespace WcfIntegration.ConsoleDemo.Scenarios
{
��� class InterceptorOnly
��� {
��� ��� public static void Run()
��� ��� {
��� ��� ��� System.Diagnostics.Debug.WriteLine("Running interceptor-only Scenario");
��� ��� ��� // SERVICE: Setup container with WCF facility
��� ��� ��� IWindsorContainer container;
��� ��� ��� container = new WindsorContainer()
��� ��� ��� ��� .AddFacility<WcfFacility>();
��� ��� ��� // SERVICE: Register WCF metadata logic
��� ��� ��� container.Register(Component
��� ��� ��� ��� .For<IServiceBehavior>()
��� ��� ��� ��� .Instance(new ServiceMetadataBehavior() { HttpGetEnabled = true })
��� ��� ��� ��� );
��� ��� ��� // SERVICE: Register interceptor
��� ��� ��� container.Register(Component.For<Misc.HelloInterceptor>());
��� ��� ��� // SERVICE: Register IHelloService with explicit implementation (HelloServiceImpl)
��� ��� ��� container.Register(Component
��� ��� ��� ��� .For(typeof(HelloService.IHelloService))
��� ��� ��� ��� .Interceptors(typeof(Misc.HelloInterceptor))
��� ��� ��� ��� // NO EXPLICIT IMPLEMENTATION .ImplementedBy<Misc.HelloServiceImpl>()
��� ��� ��� ��� .ActAs(new DefaultServiceModel()
��� ��� ��� ��� ��� .AddBaseAddresses("http://localhost:6080/HelloService/")
��� ��� ��� ��� ��� .AddEndpoints(WcfEndpoint.BoundTo(new BasicHttpBinding()))
��� ��� ��� ��� ��� )
��� ��� ��� ��� );
��� ��� ��� // SERVICE: test get service from same container
��� ��� ��� container.Resolve<HelloService.IHelloService>().Hello();
��� ��� ��� // CLIENT:
��� ��� ��� HelloService.IHelloService client;
��� ��� ��� client = ChannelFactory<HelloService.IHelloService>.CreateChannel(
��� ��� ��� ��� new BasicHttpBinding(),
��� ��� ��� ��� new EndpointAddress("http://localhost:6080/HelloService/")
��� ��� ��� ��� );
��� ��� ��� client.Hello();
��� ��� ��� // DISPOSE:
��� ��� ��� container.Dispose();
��� ��� }
��� }
}
namespace WcfIntegration.ConsoleDemo.HelloService��� ��� HelloReply HelloInOut(HelloMessage request);
{
��� [ServiceContract]
��� public interface IHelloService
��� {
��� ��� [OperationContract]
��� ��� [OperationContract]
��� ��� void HelloIn(HelloMessage request);
��� ��� [OperationContract]
��� ��� HelloReply HelloOut();
��� ��� [OperationContract]
��� ��� void Hello();
��� }
��� public class HelloMessage
��� {
��� ��� public string HelloText;
��� ��� public DateTime HelloTime;
��� ��� public Smile[] Smiles;
��� }
��� public class Smile
��� {
��� ��� public string Description;
��� ��� public bool ShowTeeth;
��� }
��� public class HelloReply
��� {
��� ��� public string HelloResponse;
��� ��� public double SmileFactor;
��� }
}
namespace WcfIntegration.ConsoleDemo.Misc
{
��� public class HelloInterceptor : IInterceptor
��� {
��� ��� public HelloInterceptor()
��� ��� { }
��� ��� #region IInterceptor Members
��� ��� public void Intercept(IInvocation invocation)
��� ��� {
��� ��� ��� System.Diagnostics.Debug.WriteLine(string.Format("HelloInterceptor: {0} @ {1}", invocation.Method.Name, DateTime.Now.ToLongTimeString()));
��� ��� ��� // DO THE IHelloService BUSINESS
��� ��� }
��� ��� #endregion
��� }
}
--------------------------------------------
2010/2/8 Craig Neuwirt <cneu...@gmail.com>
That doesn't make sense to me.ďż˝ Are you getting an exception?ďż˝ Can you send me a test case to demonstrate?
thanks,
�craig
Right. Now resolve works using the same container. Thank you.
Yet, remote WCF calls still don't work. This looks like WCF Facility do not expose services that have no implementation.
2010/2/5 Craig Neuwirt <cneu...@gmail.com>
You need to register the HelloServiceInterceptor too.
Actually I get no error when I register.
But nothing seems to come out, service is not available...
If I try getting a service client from the same container, I get an exception:
"ComponentActivator: could not proxy HelloModule.IHelloService" > "The interceptor could not be resolved".
What error do you get when you do this?
On Thu, Feb 4, 2010 at 9:50 AM, fredlegrain <f.le...@gmail.com> wrote:
I'd like to customize WCF Integration Facility to make capable of
exposing a service host based on a provided ServiceContract interface
and handling calls through a provided interceptor.
Let's say I have a ServiceContract interface :
ďż˝ ďż˝[ServiceContract]
� �public interface IHelloService {
ďż˝ ďż˝ ďż˝ ďż˝[OperationContract]
� � � �string SayHello(string message);
ďż˝ ďż˝}
Let's says I don't have (and don't want to have) any implementation of
IHelloService.
But I have an interceptor (let's call it HelloServiceInterceptor)
which knows how to answer the service calls.
I'd like to have my init code look like this :
� �container.Register(Component
ďż˝ ďż˝ ďż˝ ďż˝.For(typeof(IHelloService))
ďż˝ ďż˝ ďż˝ ďż˝.Interceptors(typeof(HelloServiceInterceptor)).First
ďż˝ ďż˝ ďż˝ ďż˝.ActAs(new DefaultServiceModel()
ďż˝ ďż˝ ďż˝ ďż˝ ďż˝ ďż˝.AddEndpoints(WcfEndpoint
ďż˝ ďż˝ ďż˝ ďż˝ ďż˝ ďż˝ ďż˝ ďż˝.BoundTo(new BasicHttpBinding())
ďż˝ ďż˝ ďż˝ ďż˝ ďż˝ ďż˝ ďż˝ ďż˝.At("http://localhost:6080/HelloService/")
ďż˝ ďż˝ ďż˝ ďż˝ ďż˝ ďż˝)
ďż˝ ďż˝ ďż˝ ďż˝)
ďż˝ ďż˝);
Do you expect that be feasible?
How can I customize Windsor and/or WCF Integration Facility to achieve
that?
Maybe a custom ServiceModel would allow me to do the job?
Cheers,
Fr�d�ric
Frédéric,
My spike code is here
http://code.assembla.com/kkozmic/subversion/nodes/Garage/WcfGHost?rev=79
Implementing this feature would enable another thing I was thinking
about (
http://castle.uservoice.com/forums/16605-official-castle-project-feedback-forum/suggestions/188895-wcf-facility-support-mixin-services?ref=title
)
Currntly in WCF when we have multiple services (classes) we need to
provide a new ServiceHost for each, which means each has its own
runtime, lots of resources are duplicated etc.
With this we could build up one big umbrella service proxy-class,
build single ServiceHost and using proxy with target interface inject
as target appropriate class (or use none and rely on interceptors or
some other mechanism) to provide implementation.
We don't really need to worry about matching lifetimes here, since we
can rely on Windsor lifectime management mechanism to do that for us.
This feels like a great feature to me (especially since I'm feeling
the pain it would alleviate, in my current project).
Am I missing something obvious here?
What do you guys think?
Krzysztof
On 12 Lut, 09:36, Frédéric Legrain <f.legr...@gmail.com> wrote:
> Craig,
> Based on my "Hello" example, I provide a DP of IHelloService as
> implementation, with HelloInterceptor to handle the requests.
> But there are some limitations. One is that there is only a single instance
> of the DP handling the requests (but is it a real problem?)
>
> Krzysztof,
> How did you make it work?
>
> 2010/2/11 Craig Neuwirt <cneuw...@gmail.com>
>
> > So what did you do to make this work?
>
> > 2010/2/11 Frédéric Legrain <f.legr...@gmail.com>
>
> >> Krzysztof,
> >> Good news you consider adding the feature to WCF Facility.
> >> I also already have a solution working with DP, just could'nt figure out
> >> if WCF Facility was already capable of it.
>
> >> Can I help on this one?
> >> I was considering providing my own customized IWcfServiceHost and/or
> >> AbstractServiceHostBuilder and/or WcfServiceModel
> >> to support the feature. Or do you consider adding this to the
> >> DefaultServiceHost/HostBuilder/Model ?
>
> >> Frédéric
>
> >> 2010/2/10 Krzysztof Koźmic <krzysztof.koz...@gmail.com>
>
> >> Frédéric, good news!
>
> >>> I was able to build a working proof-of-concept solution based on
> >>> DynamicProxy and WCF only.
> >>> We'll take a look at bringing this functionality to WCF Facility now.
>
> >>> Krzysztof
>
> >>> On 2010-02-10 20:47, Craig Neuwirt wrote:
>
> >>> Definitely a limitation. Working with Krzysztof to find the best
> >>> solution.
>
> >>> thanks,
> >>> craig
>
> >>> 2010/2/8 Frédéric Legrain <f.legr...@gmail.com>
>
> >>>> You're welcome, thanks you for your time.
> >>>> About the exception, I get it when trying to call the service (line "
> >>>> client.Hello(); " -> server actively refused connection )
>
> >>>> I am considering providing my own customized IWcfServiceHost and/or
> >>>> AbstractServiceHostBuilder and/or WcfServiceModel
> >>>> to support the feature (expose WCF service with only an interceptor to
> >>>> handle the requests).
>
> >>>> Cheers,
> >>>> Frédéric
>
> >>>> 2010/2/8 Craig Neuwirt <cneuw...@gmail.com>
>
> >>>>> Thanks,
> >>>>> I'll take a look when a get a free moment.
>
> >>>>> 2010/2/8 Frédéric Legrain <f.legr...@gmail.com>
> >>>>>> 2010/2/8 Craig Neuwirt <cneuw...@gmail.com>
>
> >>>>>>> That doesn't make sense to me. Are you getting an exception? Can
> >>>>>>> you send me a test case to demonstrate?
>
> >>>>>>> thanks,
> >>>>>>> craig
>
> >>>>>>> 2010/2/8 Frédéric Legrain <f.legr...@gmail.com>
>
> >>>>>>>> Right. Now resolve works using the same container. Thank you.
>
> >>>>>>>> Yet, remote WCF calls still don't work. This looks like WCF Facility
> >>>>>>>> do not expose services that have no implementation.
>
> >>>>>>>> 2010/2/5 Craig Neuwirt <cneuw...@gmail.com>
>
> >>>>>>>>> You need to register the HelloServiceInterceptor too.
>
> >>>>>>>>> 2010/2/5 Frédéric Legrain <f.legr...@gmail.com>
>
> >>>>>>>>>> Actually I get no error when I register.
> >>>>>>>>>> But nothing seems to come out, service is not available...
>
> >>>>>>>>>> If I try getting a service client from the same container, I get
> >>>>>>>>>> an exception:
> >>>>>>>>>> "ComponentActivator: could not proxy HelloModule.IHelloService" >
> >>>>>>>>>> "The interceptor could not be resolved".
>
> >>>>>>>>>> 2010/2/5 Craig Neuwirt <cneuw...@gmail.com>
> ...
>
> więcej >>
--
I'm sorry to revive such an old post, but the posibilities mentioned here about providing an "implementation" of services based only on interceptors sound great.Did you ever make this work? Was it included in the Wcf Facility?
--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/Wun36V0xlAQJ.
var model = container.Kernel.GetHandler(typeof(TComponent)).ComponentModel;
var proxyOptions = Castle.MicroKernel.Proxy.ProxyOptionsUtil.ObtainProxyOptions(model, true); proxyOptions.OmitTarget = true;