Search code examples
c#web-services.net-3.5asmxc#-2.0

Web services and client DLL


I have a web service and a client DLL. The web service uses an Oracle database.

For testing the client DLL, I copied the web service and made it point to a test database. Then I copied the client DLL and added this test web service using "Add web reference".

What I would like to do is to use one web service and one client DLL but be able to tell the client DLL to use either use the test or production database rather than two identical web serivces and client DLLs.

Edit

I mis-stated the issue. What I need to do is use one client DLL and two web services (one production version, one development/test version) and be able to, somehow, tell the client DLL which web services to use. This is a sample of how the web service, client DLL and client app are used:

public class DSSService : System.Web.Services.WebService
{
    public DSSService()
    {

    }
    [WebMethod(MessageName = "GetFacility", BufferResponse=true, Description = "blah.")]

    public Facility GetFacility(string sFDBID, string sZip, string sFinNo)
    {
        Facility oFacility = ...;
        ...
        return oFacility;
    }
    ....
}

Client DLL:

namespace DSSConfig
{
    string sWSURL;

    public class Config
    {
        public Config()
        {
        }

        public void SetWSURL(string sURL)
        {
            sWSURL = sURL;
        }

        public Facility GetFacility(string sFDBID, string sZip, string sFinNo)
        {
            DSSService Proxy = new DSSService();
            proxy.Url = sWSURL;
            Facility oFacility = Proxy.GetFacility(sFDBID, sZip, sFinNo);
            return  oFacility;
        }

In client application, having DSSConfig DLL as reference:

DSSConfig oConfig = new DSSConfig();
oConfig.SetWSURL("http://myserver/WebService1/service.asmx");
oConfig.GetFacility("blah", "blah", "blah");

Solution

  • What you need to do is change the WEB Service to take a parameter that it will use to construct the connection string to the DB.

    Then change client DLL to pass that parameter as part of the call or connection.

    Then you can configure the Client DLL to using any technique you like to pass the parameter. My suggestion is perhaps derive a class from the generated proxy in the client DLL and use this in the client code.

    Without specific implementation details I can't be more precise.