This post originated from an RSS feed registered with .NET Buzz
by Dave Bettin.
Original Post: Turning off WSDL Generation in WSE2
Feed Title: Dave Bettin on Services
Feed URL: http://www.davebettin.com/me/rss.aspx
Feed Description: Bettin' on .Net Service Development
As Aaron Skonnard pointed out, WSE2 does provide different ways to view the WSDL for the relevant SoapService.
He mentions for HTTP bound SoapService(s) you can just append the infamous "?wsdl" to the service's URI to retrieve the corresponding WSDL definition. To be a little more precise, the WSDL will be returned on any non-SOAP 1.1 Post. So, if you request http://localhost/MyService.ashx?dave=crazydude, the response will contain the WSDL for MyService.
That is great the service's WSDL is so accessible, however, there might be certain scenarios where I don't want the WSDL to be available. So, how the heck do I turn off the generation?
I went sniffing around the WSE2 documentation and reflector looking for a solution. Needless to say, the documentation provided no insight, but, I did manage to come up with two solutions -- WSE2 style, no IIS configurations.
1) When you create a SoapService implementation, you can override the ProcessNonSoapRequest method. The intent of this method, in SoapReceiver, is to produce the WSDL and write it out the HttpResponse buffer. This method is called on every HTTP SoapService non-SOAP 1.1 Post. Therefore, to impede the generation of WSDL, don't call the base method.
We can change the handler configuration to only accept requests for HTTP post requests, therefore, denying any chance of the ProcessNonSoapRequest method executing. If I recall correctly, a HTTP status code of 401 is returned.
Hopefully, these solutions provide to be useful for someone other than myself.