Create an ASMX web service from a WSDL file

后端 未结 2 1080
不思量自难忘°
不思量自难忘° 2020-12-13 12:07

I have a WSDL file and I am trying to create a web service that conforms to the WSDL.

I\'ve created clients using WSDL files that consume an existing service, but I\

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 12:39

    If you already created interfaces you need to implement those interfaces.
    Just create a new web service and add the interface that you generated so that it inherits from that interface. Visual Studio can automatically generate stubs for every method in interface. Mark them with the WebMethod attribute and put some code in that will return some test data/results.

    If you have this interface (with some more attributes that were automatically generated):

    
    public interface IRealWebService
    {
        string GetName();
    
    }
    

    You should make a new service:

    
    public class WebTestService : System.Web.Services.WebService, IRealWebService
    {
    
        #region IRealWebService Members
    
        [WebMethod]
        public string GetName()
        {
            return "It Works !!!!";
        }
        #endregion
    }
    

提交回复
热议问题