2012-06-29 64 views

回答

1

创建像这样使用asp.net兼容模式一类...

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

//Some methods 

} 

注册类在Global.asax文件作为Web服务

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))); 
    } 
} 

如果您的应用程序正在运行在端口8080上,您可以点击服务

http://localhost:8080/myServiceUrl