简体   繁体   中英

How to create a WSDL from a C# method?

I have a C# application, and now I need to create a web service from a method that already exist in a windows form app.

Whats the best way to do this ?

Can I generate a wsdl file just for the file or methods that I want to expose ? And then, how can I put it in the IIS, my application is client-server, so, it isn´t in the IIS yet.

Thanks

If you have code that you have multiple applications accessing, I would split them off into their own dlls and reference it in each application that needs access to it. This is easier to manage.

Create a WCF Service Application Project. This will create the structure needed to host the service via IIS.

IService1 will be your interface. You will create a OperationContract here

[OperationContract]
string HelloWorld();

In Service1.svc you will add code that you will access your dll

public string HelloWorld()
{
    return MyClassFromDll.HelloWorld();
}

In your project that will access the service you will add a service reference pointing to the IIS server hosting your service. This will automatically add the needed code to your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM