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.
Here is an example:
1 public class WsdlGeneration : SoapService
2 {
3 protected override void ProcessNonSoapRequest(HttpContext httpContext)
4 {
5 //base.ProcessNonSoapRequest(httpContext);
6 // return;
7 throw new HttpException(404,null);
8 }
9
10 [SoapMethod("urn:hello:world")]
11 public string HelloWorld()
12 {
13 return "Hello World";
14 }
15
16 }
2) When you create a HTTP SoapService, you must correctly configure the service with a httpHandler configuration element in the web.config.
For example:
<
httpHandlers>
<add verb="*" path="HelloWorld.ashx" type="Wse2.HttpServices.HelloWorld, Wse2.HttpServices" />
</httpHandlers>
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.
<httpHandlers>
<add verb="POST" path="HelloWorld.ashx" type="Wse2.HttpServices.HelloWorld, Wse2.HttpServices" />
</httpHandlers>
Hopefully, these solutions provide to be useful for someone other than myself.
Read: Turning off WSDL Generation in WSE2