Web service vs. Web service referencing DLL
i'm particularly new in developing web services. I have this existing web service i need to redo because currently it doesn't seem to work,
The web service has a references to a DLL Class
<%@ WebSe开发者_开发百科rvice Language="C#" Class="MyClass"%>
that's the whole content...and it has a MyClass.dll located in a bin folder
What i did is put the MyClass class inside the Web service itself....
<%@ WebService Language="C#" Class="MyClass"%>
using System;
using System.IO;
using System.Data;
//...
[GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[WebServiceAttribute(Namespace = "http://service.search.lsc.slacker.com")]
[WebServiceBindingAttribute(Name = "TLSCSoap22Binding", Namespace = "http://service.search.lsc.slacker.com")]
public class MYClass: System.Web.Services.WebService
{
//...
}
and it did work, tested all the functions and everything worked as expected.
However, i need to see all the repercussions before proposing this solution, i might have overlooked the benefits of referencing a dll instead
Please note that i cannot ask the previous developer of why it was encapsulated in a DLL file and i know for a fact that this DLL will not be reusable by any other external apps. It was created solely for the web service.
So my question is why did the old developer created a dll to contain the class and be consumed by a web service, instead of just a web service?
Perhaps the developer's original intention was to have the functionality spread over several DLL's and the web service to act as the gateway to all of the DLL's?
If the previous developer created the web service in Visual Studio using one of the pre-defined web service templates - the code-behind model is how the project would have been structured out-of-the-box.
In your example, the original asmx page isn't referencing the class using the classes namespace. Missing the namespace in the MyClass
reference could have been causing the problems with the service not working correctly (although that's just a longshot guess because you didn't really give much more information than "the service doesn't work").
Hope that helps!
There could be several reasons. The original developer may have intended to black box the dll for external usage. It's possible the other developer had a custom-built, "in the can" test harness for testing libraries of this nature. Precompiled dlls are a little more secure during the SDLC because intermediate agents can't impact the code behind. Code in a web service that is not compiled can be edited accidentally (or with malicious intent even).
In the end, it could just have been the guy's preference. The decision really is fairly arbitrary unless you have some outside factor as an influence.
精彩评论