katie77
katie77

Reputation: 1811

How to host a webservice on IIS with dll

I need to host a webservice on IIS. I did this before where I will have an .svc(WCF) file or amsx file. But never did it with just a dll. How should I set it up?

Upvotes: 0

Views: 1421

Answers (1)

Mike
Mike

Reputation: 653

Create a class like so using asp.net compatability mode...

[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode =  AspNetCompatibilityRequirementsMode.Required)]
public class MyService    
{

//Some methods

}

Register the class in your global.asax file as a web service

public class Global : System.Web.HttpApplication
{

    public void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes();
    }

    private static void RegisterRoutes()
    {
        RouteTable.Routes.Add(new ServiceRoute("myServiceUrl", new WebServiceHostFactory(), typeof(MyService)));
    }
}

if your app was running on port 8080 you could then hit the service at

http://localhost:8080/myServiceUrl

Upvotes: 1

Related Questions