Using PIAB with asmx web services Options

Topics: General Discussion Forum
Aug 3, 2009 at 5:49 AM
Hello All,

I need to use PIAB in some asmx web services that I "inherited". I am
familiar with the use of the PIAB with applications and WCF web
services but don't know how to proceed in the asmx scenario. These web
services are used by the clients via some proxies that compose our
client side SDK.

My question comes from the fact that, to enable policy injection, I
need to use PolicyInjection.Create when instantiating my classes. This
is simple in the case of an application: just replace the calls to new
with calls to PolocyInjection.Create but I don't know how to do this
in the case of a asmx web service, in which case the object is
instantiated implicitly. Since the app block requires the caller to
instantiate a proxy for the target object through the app block
itself, I would assume some HTTP handler would have to be created to
intercept .asmx requests. Is this something where WSSF could help? ...How? 

For example,  I would like to have the following:

WebService(Namespace = "http://www.MyDomain.com/")
WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)
ToolboxItem(false)
public class WebServiceClass : System.Web.Services.WebService
{
Tag("Injector")
public int MyWebServiceMethod(string value)
{

 

}
}

What I am unaware of is how this would work with web services given
that the methods are called directly, and as far as I'm aware the
object is created indirectly.

Any advise would be greatly appreciated.

Kind regards

CD

Developer
Aug 3, 2009 at 12:01 PM

You can get some idea of PIAB usage with WSSF with this contrib project "The EntLib 4.0 Policy Extensions":

"The goal of these extensions is to simplify the task of integrating PIAB (Policy Application Block) and WCF by providing some features like, design time support for applying policies to services, generating a host config with all the required sections that points to the specified entlib config file and implementing a WCF behavior that abstracts you from wrapping or creating objects using the PIAB factory."

Regarding its use on ASMX services, you may get some ideas from the above project and the interception strategy and adapt that to ASMX following some ideas regarding WebServiceHandlerFactory here and here.

Regards,

Hernan