Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom WSDL for an ASMX Web Service

Is it possible to use a custom WSDL with a .NET WebService? I would like to use a custom WSDL with my .NET WebService instead of the one generated by .NET as part of my WebService.

like image 808
Bryan Avatar asked Feb 25 '23 06:02

Bryan


1 Answers

Actually there is a way to do this: You can create your own WSDL (i.e. removing methods you don't want to publish) and then make it available at a dedicated spot, this allows users to bind to it as normal.

To prevent users from just retrieving the default WSDL (foo.asmx?wsdl) you have to flip a switch in the web.config of your web service:

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

From the relevant MSDN section:

Note Removing the Documentation protocol also disables WSDL file generation for any XML Web services within the Web application. This prevents clients from generating a proxy class unless a custom WSDL file is created and provided for them.

like image 50
BrokenGlass Avatar answered Mar 03 '23 05:03

BrokenGlass