Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
WCF and IEndpointBehavior
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Phillip Haydon  
View profile  
 More options Nov 2 2011, 8:37 pm
From: Phillip Haydon <phillip.hay...@gmail.com>
Date: Wed, 2 Nov 2011 17:37:58 -0700 (PDT)
Local: Wed, Nov 2 2011 8:37 pm
Subject: WCF and IEndpointBehavior
Hey,

I'm trying to apply a Unit Of Work similar to what's described here:

http://ianfnelson.com/archives/2010/04/09/wcf-nhibernate-unit-of-work...

Since I can't find any other ways to do it. How can I achieve this
with Autofac, and is there a better way of doing it?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Travis Illig  
View profile  
 More options Nov 3 2011, 12:50 pm
From: Travis Illig <travis.il...@gmail.com>
Date: Thu, 3 Nov 2011 09:50:32 -0700 (PDT)
Local: Thurs, Nov 3 2011 12:50 pm
Subject: Re: WCF and IEndpointBehavior

To the best of my knowledge, Autofac doesn't have a feature to do DI into
endpoint behaviors, so you'd have to resolve the dependency manually. (Nick
will, I'm sure, jump in here and correct me if I'm wrong.) So in your
behavior where you need your IUnitOfWork as a constructor parameter, you'd
instead resolve it directly:

public UnitOfWorkEndpointBehavior()
{
  this.unitOfWork = AutofacHostFactory.Container.Resolve<IUnitOfWork>();

}

You can still apply behaviors through XML configuration using Autofac, just
like normal, but if you want to do it programmatically you can have a
custom host factory based on AutofacServiceHostFactory and use the
ConfigurationAction static property

UnitOfWorkAutofacHostFactory.ConfigurationAction =
  host =>
    host.Opening += (sender, args) =>
      host.Description.Behaviors.Add(new UnitOfWorkEndpointBehavior());

Then specify the custom UnitOfWorkAutofacHostFactory in your .svc file as
the service host factory.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Phillip Haydon  
View profile  
 More options Nov 3 2011, 9:10 pm
From: Phillip Haydon <phillip.hay...@gmail.com>
Date: Thu, 3 Nov 2011 18:10:46 -0700 (PDT)
Local: Thurs, Nov 3 2011 9:10 pm
Subject: Re: WCF and IEndpointBehavior
Hmm, The Behaviors takes in IServiceBehavior rather than
IEndpointBehavior

If I set it up to use a ServiceBehavior it get's injected once, and
never again, I guess that the service behavior is newed up once?

The same thing happens with the EndPointBehavior.

I stepped through all the code and it seems that the
CallContextInitializer is created once, and BeforeInvoke/AfterInvoke
are called every request, so I would need to pass a IContainer down to
the CallContextInitializer and resolve a new IUnitOfWork BeforeInvoke
and commit it AfterInvoke.

What has confused me is the article relies on the fact that the
UnitOfWork is created once, and it's role is simply to Open a NH
Session and Transaction, and Commit it later.

I want a new UnitOfWork created for each request which wasn't
happening.

I think I've solved my problem, it's a little bit work, will have to
write my own ServiceBehavior, EndpointBehavior, and
CallContextInitializer, and pass the Autofac IContainer in for it to
resolve the UnitOfWork, but it will do what I want it to do :)

On Nov 4, 3:50 am, Travis Illig <travis.il...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Phillip Haydon  
View profile  
 More options Nov 3 2011, 11:47 pm
From: Phillip Haydon <phillip.hay...@gmail.com>
Date: Thu, 3 Nov 2011 20:47:18 -0700 (PDT)
Local: Thurs, Nov 3 2011 11:47 pm
Subject: Re: WCF and IEndpointBehavior
Nope, no luck, passing in the IContainerContext or ILifetimeContext
and resolving the Unit of Work:

public object BeforeInvoke(InstanceContext instanceContext,
IClientChannel channel, Message message)
{
    var uow = _container.Resolve<IUnitOfWork>();

    uow.Begin();

    return null;

}

public void AfterInvoke(object correlationState)
{
    var uow = _container.Resolve<IUnitOfWork>();

    uow.Commit();

}

Causes two different instances to be returned. They aren't in the same
scope. :(

builder.RegisterType(typeof (UnitOfWork))
        .As(typeof (IUnitOfWork))
        .InstancePerLifetimeScope()
        .OnRelease(x =>
                        {
                            ((IUnitOfWork) x).Commit();
                        });

This however, seems to work fine. But seems real hacky...

On Nov 4, 12:10 pm, Phillip Haydon <phillip.hay...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Phillip Haydon  
View profile  
 More options Nov 5 2011, 11:23 am
From: Phillip Haydon <phillip.hay...@gmail.com>
Date: Sat, 5 Nov 2011 08:23:47 -0700 (PDT)
Local: Sat, Nov 5 2011 11:23 am
Subject: Re: WCF and IEndpointBehavior
I've posted my current solution here if anyone cares :)

http://www.philliphaydon.com/2011/11/unit-of-work-with-wcf-and-autofac/

If anyone has any feedback on it, would be appreciated.

On Nov 4, 2:47 pm, Phillip Haydon <phillip.hay...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicholas Blumhardt  
View profile  
 More options Nov 6 2011, 9:21 pm
From: Nicholas Blumhardt <nicholas.blumha...@gmail.com>
Date: Sun, 6 Nov 2011 18:21:26 -0800
Local: Sun, Nov 6 2011 9:21 pm
Subject: Re: WCF and IEndpointBehavior

Hi Phillip - thanks for the follow up, glad you were able to sort something
out.

Nick

On 5 November 2011 08:23, Phillip Haydon <phillip.hay...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Phillip Haydon  
View profile  
 More options Nov 7 2011, 12:28 am
From: Phillip Haydon <phillip.hay...@gmail.com>
Date: Sun, 6 Nov 2011 21:28:08 -0800 (PST)
Local: Mon, Nov 7 2011 12:28 am
Subject: Re: WCF and IEndpointBehavior
Hey Nick,

I've sort of decided to just use my UoW like:

using (UnitOfWork)
{

}

In my service, because unlike MVC I can't find a good spot in WCF to
capture an exception and roll the transaction back. So without
manually capturing all exceptions in code I don't feel it's a
bulletproof solution yet :(

I'm going to have another play this weekend, see if I can find a good
way of being able to roll the transaction back on exception.

Cheers.

Phill

On Nov 7, 1:21 pm, Nicholas Blumhardt <nicholas.blumha...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
karampelaskos...@gmail.com  
View profile  
 More options Mar 20, 2:39 am
From: karampelaskos...@gmail.com
Date: Mon, 19 Mar 2012 23:39:50 -0700 (PDT)
Local: Tues, Mar 20 2012 2:39 am
Subject: Re: WCF and IEndpointBehavior

Hi Nick,

I think this is an interesting feature for adding into
Autofac.WcfIntegration, that is the ability to have Autofac handle the
creation of EndPointBehaviors. I don't know if it is doable and if WCF
provides the wiring for that, but it sure would be useful... Are there any
plans for it?

Btw, and since this is my first time posting here, great job on Autofac,
absolutely loving it.

Thanks,
Kostas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicholas Blumhardt  
View profile  
 More options Mar 25, 11:13 pm
From: Nicholas Blumhardt <nicholas.blumha...@gmail.com>
Date: Sun, 25 Mar 2012 20:13:15 -0700
Local: Sun, Mar 25 2012 11:13 pm
Subject: Re: WCF and IEndpointBehavior

Thanks Kostas. No current plans I'm aware of, but others on this list who
spend more time with WCF may have some thoughts here.

Cheers!
Nick

On 19 March 2012 23:39, <karampelaskos...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Meyer-Gleaves  
View profile  
 More options Mar 26, 10:07 am
From: "Alex Meyer-Gleaves" <alex.meyerglea...@gmail.com>
Date: Tue, 27 Mar 2012 00:07:51 +1000
Local: Mon, Mar 26 2012 10:07 am
Subject: RE: WCF and IEndpointBehavior

Hi Kostas,

In the case of self-hosting you have to add the endpoint behaviors to the
Behaviors collection on the service endpoint before opening the service
host, so you could resolve any instances of IEndpointBehavior from the
container and add them before opening the host manually. For IIS hosting, we
could resolve the behaviors from the container for you and add them before
opening the service host. Do you have a particular scenario in mind?

Cheers,

Alex.

From: autofac@googlegroups.com [mailto:autofac@googlegroups.com] On Behalf
Of Nicholas Blumhardt
Sent: Monday, 26 March 2012 1:13 PM
To: autofac@googlegroups.com
Subject: Re: WCF and IEndpointBehavior

Thanks Kostas. No current plans I'm aware of, but others on this list who
spend more time with WCF may have some thoughts here.

Cheers!
Nick

On 19 March 2012 23:39, <karampelaskos...@gmail.com> wrote:

Hi Nick,

I think this is an interesting feature for adding into
Autofac.WcfIntegration, that is the ability to have Autofac handle the
creation of EndPointBehaviors. I don't know if it is doable and if WCF
provides the wiring for that, but it sure would be useful... Are there any
plans for it?

Btw, and since this is my first time posting here, great job on Autofac,
absolutely loving it.

Thanks,

Kostas

--
You received this message because you are subscribed to the Google Groups
"Autofac" group.

To view this discussion on the web visit
https://groups.google.com/d/msg/autofac/-/POvGWPCUtpEJ.

To post to this group, send email to autofac@googlegroups.com.
To unsubscribe from this group, send email to
autofac+unsubscribe@googlegroups.com
<mailto:autofac%2Bunsubscribe@googlegroups.com> .
For more options, visit this group at
http://groups.google.com/group/autofac?hl=en.

--
You received this message because you are subscribed to the Google Groups
"Autofac" group.
To post to this group, send email to autofac@googlegroups.com.
To unsubscribe from this group, send email to
autofac+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/autofac?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »