Custom WSDL for ASMX Web Service

Can I use my own WSDL with .NET WebService? I would like to use a custom WSDL with my .NET WebService, and not the one that was created by .NET as part of my WebService.

+4
source share
2 answers

There is actually a way to do this: You can create your own WSDL (i.e., remove methods that you don’t want to publish) and then make it available in a dedicated place, this allows users to bind to it as usual.

So that users do not just retrieve the default WSDL ( foo.asmx?wsdl ), you need to turn the switch in the web.config of your web service:

  <webServices> <protocols> <remove name="Documentation"/> </protocols> </webServices> 

In the appropriate MSDN section :

Note Deleting the documentation protocol also disables the generation WSDL file for any XML web services in the web application. This prevents clients from creating a proxy class if a custom WSDL file is created and provided for them.

+8
source

I assume that you want to replace the file created by .NET when your service hit the query string "? Wsll" on it.

No, there is no direct way to do this. Instead, just post your .wsdl on a website and tell the consumers of your service to get it from there. There is no standard message that "? Wsdl" is the only way to get a WSDL file.

0
source

Source: https://habr.com/ru/post/1337557/


All Articles