tags:

views:

35

answers:

1

Hello,

I have an old school ASP (note: not ASP.NET) web site that has a file called "listener.asp". This file is the interface to the "web service api". This file is on a machine that I cannot access for a while due to maintenance and implementation. However, I have been given a bunch of xml files. These xml files end with "*Request.xml" and "*Response.xsd".

My question is, can I implement my code to interact with through these .xml and .xsd files without needed to hit listener.asp? I know that I will not get any real data. But I thought there may be a way to build my app until the machine is available. Is there any way to do this?

I guess I'm assuming there is a reason for these .xml and .xsd files. I think that reason is to "define" the request and response objects. But I would like to figure out a way to code and test without having to rely on that machine. Is this possible with what I've been given?

Thank you

A: 

The best way would be to define an abstract class that provides access to your "web service api". Then create two derived classes, one that works with the real web service and one that retrieves fake responses from the files.

abstract class LegacyWebService
{
    public abstract int Foo();
}

class RealLegacyWebService : LegacyWebService
{
    public override int Foo()
    {
        return (int)XDocument.Load("http://www.example.com/foo").Root;
    }
}

class FakeLegacyWebService : LegacyWebService
{
    public override int Foo()
    {
        return (int)XDocument.Load(@"C:\Users\Me\Desktop\foo.xml").Root;
    }
}

You should also be able to create C# classes from your xsd files and use XML serialization to convert the XML responses from the web service or the file to C# objects.

dtb