WCF Service Contained In Assembly?

Last post 07-03-2009 7:47 PM by Scott927. 2 replies.

Sort Posts:

  • WCF Service Contained In Assembly?

    07-03-2009, 4:34 PM
    • Participant
      989 point Participant
    • Scott927
    • Member since 09-20-2006, 12:53 AM
    • Phoenix, AZ
    • Posts 181

    Hello everyone,

    I've been toying around a bit with WCF services and I'm giving myself a learning project to work on. Basically what I want to do is write a new custom control that is encapsulates some WCF-based functionality. I'd like to be able to add this control to my web project and enable an AJAX-based call to a WCF service. My custom control will be reponsible for rendering the appropriate javascript code to initiate the call to a WCF service, which is simply responsible for reading some values from the Cache object, and updating the page with the results that were just returned from the WCF service.

    From what I've read, all WCF services need to be created in a page with a .svc extension. However, I don't want to have to include a .svc file with my control. I'd like the .DLL file for the control to INCLUDE the service, if that's possible.

    I'm not sure if I'm taking the right approach here or not, so basically there are two questions:

    1) Is it possible to encapsulate a .svc file inside of the assembly I'll be creating the control in, so that where my control is deployed, the necessary service is deployed with it? If it is, how? And how what code would I need to add in order to provide my ScriptManager control with a reference to the service?

    2) If not, does anyone have recommendations for an alternate approach? I might be over-complicating it here. I chose a WCF service because one, I wanted to experiment with it and two, I know it can be called from client-side code quite easily.

    Thanks,

    Scott

    Scott M Schluer
    ---
    MCPD: ASP.NET Developer 3.5
  • Re: WCF Service Contained In Assembly?

    07-03-2009, 6:34 PM
    Answer
    • Participant
      1,465 point Participant
    • yaronn01
    • Member since 11-24-2006, 3:48 PM
    • Jerusalem
    • Posts 220

    I don't think this is the correct approach.

    The service should be decoupled from any other service/ui/control. Their deployment might be on different machines, in different projects etc.

    Also the deployment of a service raises considerations like security, url, load balancing, configuration and etc. Some of this will have to be done by your clients, they can't just deploy the service as it.

    Having said that, you can put the code for your service in a "service library" dll which customers can use when they host the service.

    For an out of the box experience you might consider a self hosting service:

    http://webservices20.blogspot.com/2009/06/wcf-self-hosting-project-template.html

    (even though in production customer will probably want to use iis).

    http://webservices20.blogspot.com/
    Web Services Performance, Interoperability And Testing Blog
  • Re: WCF Service Contained In Assembly?

    07-03-2009, 7:47 PM
    • Participant
      989 point Participant
    • Scott927
    • Member since 09-20-2006, 12:53 AM
    • Phoenix, AZ
    • Posts 181

    I would agree with the fact it should be decoupled in most cases. For example, if I want to expose data in my database or something along those lines. But for this project, the only reason I'm using a WCF service is so that I can access the function via a Javascript call In fact, that's part of what led me to believe I'm taking the wrong approach.

    I may start a new thread asking what the correct approach to this project would be (creating a custom control that can make it's own AJAX calls to retrieve data or save data to the cache object).

    Scott M Schluer
    ---
    MCPD: ASP.NET Developer 3.5
Page 1 of 1 (3 items)