The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Turning off WSDL Generation in WSE2

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Dave Bettin

Posts: 94
Nickname: dbettin
Registered: May, 2004

Dave Bettin is a .Net Service Developer
Turning off WSDL Generation in WSE2 Posted: Jun 6, 2004 9:19 AM
Reply to this message Reply

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
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Dave Bettin
Latest Posts From Dave Bettin on Services

Advertisement

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

Topic: I'm on Skype Previous Topic   Next Topic Topic: .NET User Group Franken trifft sich erneut in Juni

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use