Solved

How to share modules between WCF webservices..

Posted on 2010-09-16
5
498 Views
Last Modified: 2012-06-22
Hi guys,

I've got a question that I thought I'd find the answer to pretty quickly, but that I'm now into my third day and can't find the answer..

We have created our first WCF webservice.  This will not be our only webservice.  We'd like to know what strategy (if any) can be used to share class modules across the webservices without having to recompile the webservices?    

On our ASP.NET site we can just copy a .cs file into the app_code directory and the website automatically uses the new code without having to publish the whole website.  Can we achieve a similar result with webservices? Basically, we'd like to create the interface and implementation in the webservice dll but only reference outside modules instead of including them in.  We'd like to be able to overwrite an existing module and have the webservice start using it without having to recompile and re-deploy the webservice.  

Is this possible?   I can't seem to find documentation on best practice for webservice design in this area.  Any help or link to a resource that discusses this would be very much appreciated.

Thanks in advance =)
-Alan
0
Comment
Question by:aamado
  • 3
  • 2
5 Comments
 
LVL 18

Expert Comment

by:DarrenD
ID: 33699300
Hi Alan,

I'm just trying to get my head around your architecture and what you are trying to do.

This is supposed to represent a web page communicating with a WCF Web Service which communicates with outside DLL's / .cs files are you call them. An you want to be able to drop in newer versions of the outside DLL's/ cs files. The problem is that the webservice and the DLL's are compiledIs this correct?

                                                       /-> Outside DLL's modules
Web page <-> WCF/Web Services <-> Outside DLL'smodules
                                                       \-> Outside DLL'smodules

Or is it that you want to be able to actually rewrite the code.

                                                       /-> Outside modules .cs file
Web page <-> WCF/Web Services <-> Outside modules .cs file
                                                       \-> Outside modules .cs file

There are two things that I can think of, one is on this link http://msdn.microsoft.com/en-us/library/ms733766.aspx The other thing I can think of for the latter is the Code DOM. But I'm not 100% it would work for what you want exactly. It's something to look at though http://www.15seconds.com/issue/020917.htm


Cheers,

Darren
0
 
LVL 18

Expert Comment

by:DarrenD
ID: 33699315
Hi again,

Provided the interface doesn't change then you should be fine with whatever you do.

I think the first link I posted is the one you want although compiling it into a DLL will work either.

Cheers,

Darren
0
 

Author Comment

by:aamado
ID: 33705211
Hi Darren =)

Thanks for the reply,

The second example you stated is basically what we're trying to achieve.

Here's an image that would represent an example of the webservice file structure on our webserver.

Hopefully this will help explain better what i'm asking..

We would like to just be able to overwrite one of the classes (i.e. Myfunctions1.cs) and have the webservice start using it without having to recompile and publish out the webservice.

Right now what is happening is that when publishing out the webservice, the MyFunctions1.cs and Myfunctions2.cs files get compiled into the Service1.dll and that's what the Webservice references.

In our Asp.net websites we can just replace the .cs files in the App_Code directory and the website will just compile the .cs file on the fly and use it right away.

I'm not sure if that type of architecture is possible with webservices.  That's what we're trying to find out.

Thanks again,
-Alan =)
Example.jpg
0
 
LVL 18

Accepted Solution

by:
DarrenD earned 125 total points
ID: 33707596
Hi Alan,

I think that what you want is exactly what is in  the first link that I gave you as you do not have to compile into a DLL as this is done on the fly: http://msdn.microsoft.com/en-us/library/ms733766.aspx

I have tested this. Simply create a directory in IIS called IISServiceTest and add a sub directory call App_Code.

Then add the attached files to the following directories:

IISServiceTest/Web.Config
IISServiceTest/CalcService.svc
IISServiceTest/App_Code/Service.cs
IISServiceTest/App_Code/Functions1.cs

You should then be able to change the functions in Functions1.cs

This way you do not create a DLL. It is all done on the fly.

However the client will have to get the latest version of the Service Contract if new methods are added to it so that the client can see them. Services are different in that respect to normal ASP.NET

NB: Change CalcService.cs to CalcService.svc as EE would not let me upload it.

Let me know if this meets some of your requirements.

Hope this helps,

Darren



IISHostedCalcService.zip
0
 

Author Comment

by:aamado
ID: 33708424
Hi Darren  :)

Yes that's perfect!  Just what we're looking for.  I didn't understand the link as well as I did the explanation in your last post,  thank you for that :)

Thanks again!
-Alan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will show you how to add an attribute to an XML (http://en.wikipedia.org/wiki/XML) stream returned from a Windows Communication Foundation (http://en.wikipedia.org/wiki/Windows_Communication_Foundation) (WCF) Web Service.  Some knowled…
In previous Articles, we have discussed how we can upload a file using .asmx web service and isolated storage space. Here, in continuation to the topic, I am going to discuss how we can use WCF for the same purpose. Steps: 1.Create the silverli…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now