Search This Blog

Thursday, April 4, 2013

ASP.NEW web service creation - top down

sometime you want to create a mockup web service based on wsdl files that you get from the client.
the client sent to you the wsdl file , because he not allowed to access to his domain while developing the solution.

the easy way to create such service is with in your domain for testing.
you can do so via wsdl.exe program that ship with MS VS2008/2012 (Visual Studio 2008 Command Prompt).

if you have external xsd file that linked from the wsdl , add it to the command after the wsdl file.

e.g.
wsdl.exe my_demo.wsdl my_demo.xsd /l:CS /serverInterface /out:D:\MyStuff\ServerGenCode

the above command generates the interface file is D:\MyStuff\ServerGenCode directory based on the wsdl file and the xsd.

after generating the interface file , you need to implement the interface
e.g.
public class WebTestService : System.Web.Services.WebService, IMyDemo
{

    #region IMyDemo Members
    [WebMethod]
    public string GetName()
    {
     return "It Works !!!!";
    }
    #endregion 
}

enjoy
Yaniv Tzanany

No comments: