[Mono-list] Webservise Discovery Language
Ben Clewett
ben at roadrunner.uk.com
Wed Nov 8 10:32:25 EST 2006
Kornél,
Thanks for the info. I am using the default from SUSE 10.1:
mono 1.1.13.8
mod_mono 1.1.15.5
There is no version number against this bug-fix so I don't know whether
my version should work or not.
Thanks for the extended code, I'll try to implement it.
In my case our applications do not use the GET method. So this has
provided me a very simple method of toggling the exposure to
documentation and discovery.
I have learnt a lot about mod_mono in the last two days :)
Regards,
Ben
> Hi,
>
> Web.config should be watched as well by recent stable releases.
> See bug #78505: http://bugzilla.ximian.com/show_bug.cgi?id=78505
> I suggest you to use the stable releases instead of maintenance releases.
>
> Using Application events is just as good as creating a wrapper around an
> other handler.
>
> Also note that System.Web.Secrives uses a more complex code to determine
> whether the request is a "Documentation" request. For the exact details
> have a look at GuessProtocol in
> mcs/class/System.Web.Services/System.Web.Services.Protocols/WebServiceHandlerFactory.cs
>
>
> I think that disallowing GET methods without path info is safer. But in
> this case you have to check whether it is a web service request. And I
> prefer handler wrappers because that makes easier to catch all web
> service requests.
>
> I attached a sample implementation as well.
>
> Kornél
>
> ----- Original Message ----- From: "Ben Clewett" <ben at roadrunner.uk.com>
> To: "Kornél Pál" <kornelpal at gmail.com>
> Cc: <mono-list at lists.ximian.com>
> Sent: Wednesday, November 08, 2006 12:46 PM
> Subject: Re: [Mono-list] Webservise Discovery Language
>
>
>> Kornél,
>>
>> I am making progress. You code seems to work well, I've just got to
>> tidy it a bit.
>>
>> You asked me to report a bug if a change in the Web.config is not
>> respected by mod_mono without a restart. I think I have a candidate
>> for a bug:
>>
>> I have added this to Web.config:
>>
>> <system.web>
>> <webServices>
>> <protocols>
>> <remove name="Documentation"/>
>> </protocols>
>> </webServices>
>> ....
>> ....
>> ....
>> <system.web>
>>
>>
>> This is not respected without a restart. But otherwise works well.
>>
>> -----------<>------------
>>
>> Secondly.
>>
>> For use of other members, I have found this great code snipit for
>> Global.asax:
>>
>> protected void Application_BeginRequest(Object sender, EventArgs e)
>> {
>> string requestPath = Request.RawUrl.Trim().ToLower();
>>
>> if (!my_static_global_flag) {
>> if (requestPath.IndexOf("?wsdl") > 0 ||
>> requestPath.IndexOf("?disco") > 0)
>> throw new HttpException(404, "Access Denied.");
>> }
>> }
>>
>> This also helps give me good control over visibility of my webservices.
>>
>> -----------<>------------
>>
>> Thanks for the help,
>>
>> Ben
>>
>>
>>
>>
>> Kornél Pál wrote:
>>> Hi,
>>>
>>> I attached a reference implementation in
>>> OptionalDiscoveryRequestHandler.cs.
>>>
>>> You can control it using the internal
>>> OptionalDiscoveryRequestHandler.EnableDiscovery field.
>>>
>>> The only thing you have to do is to compile the handler to a DLL
>>> (don't require it's own assembly, you can put into any existing
>>> assembly) and reference this type in Web.config instead of
>>> System.Web.Services.Discovery.DiscoveryRequestHandler.
>>>
>>> Kornél
>>>
>>> ----- Original Message ----- From: "Ben Clewett" <ben at roadrunner.uk.com>
>>> To: "Kornél Pál" <kornelpal at gmail.com>
>>> Cc: <mono-list at lists.ximian.com>
>>> Sent: Tuesday, November 07, 2006 7:05 PM
>>> Subject: Re: [Mono-list] Webservise Discovery Language
>>>
>>>
>>>> Kornél,
>>>>
>>>> I am very exited about your suggestion, I think this is exactly what
>>>> I'm looking for.
>>>>
>>>> But this level of experience is way about my knowledge. If you
>>>> could share this, I would be interested.
>>>>
>>>> Many thanks,
>>>>
>>>> Ben
>>>>
>>>>
>>>> Kornél Pál wrote:
>>>>> ASP.NET applications should reload automatically on Web.config
>>>>> change so there should be no need for restarting mod-mono-server
>>>>> (if you mean that on mono). If you have a problem like that please
>>>>> file a bug report.
>>>>>
>>>>> If you mean the Web.config modification described on
>>>>> http://msdn2.microsoft.com/en-us/library/tewz1055.aspx in "To
>>>>> enable dynamic discovery for a Web service" I suggest you to create
>>>>> your own IHttpHandler implementation that wraps
>>>>> System.Web.Services.Discovery.DiscoveryRequestHandler and that will
>>>>> make you able to disable it based on static fields or your own
>>>>> configuration files. If you use this method I can send you a simple
>>>>> implementation of this.
>>>>>
>>>>> You are using some other Web.config settings please let me know
>>>>> what exactly do you use.
>>>>>
>>>>> Kornél
>>>>>
>>>>> ----- Original Message ----- From: "Ben Clewett" <ben at clewett.org.uk>
>>>>> To: "Kornél Pál" <kornelpal at gmail.com>
>>>>> Cc: <mono-list at lists.ximian.com>
>>>>> Sent: Tuesday, November 07, 2006 6:41 PM
>>>>> Subject: Re: [Mono-list] Webservise Discovery Language
>>>>>
>>>>>
>>>>>> Kornél Pál wrote:
>>>>>>> Web.config is intended to do configuration. What exactly is your
>>>>>>> problem with that?
>>>>>>
>>>>>> Hi Kornél,
>>>>>>
>>>>>> Thanks for the reply.
>>>>>>
>>>>>> I have six servers to manage. We sometimes release ten version of
>>>>>> code a day, which over-write the Web.config. Editing this file is
>>>>>> potentially dangerous. After an edit, I have to re-start the mono.
>>>>>>
>>>>>> My feeling is that this file must be interoperated by some part of
>>>>>> the Mono suit (stop me if this is wrong.) It would be much better
>>>>>> for me if control could be administered by some simple flag. Or
>>>>>> even a static public variable in mono.
>>>>>>
>>>>>> If this is not possible, it's not so important. I am just
>>>>>> interested to know if there is an alternate method.
>>>>>>
>>>>>> I can't be the only member who would like better control of this.
>>>>>> Alternatively, do any members have scripts to toggle the
>>>>>> Webservice Discovery which are safe and fast?
>>>>>>
>>>>>> Thanks again,
>>>>>>
>>>>>> Ben
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Kornél
>>>>>>>
>>>>>>> ----- Original Message ----- From: "Ben Clewett"
>>>>>>> <ben at roadrunner.uk.com>
>>>>>>> To: <mono-list at lists.ximian.com>
>>>>>>> Sent: Tuesday, November 07, 2006 5:38 PM
>>>>>>> Subject: [Mono-list] Webservise Discovery Language
>>>>>>>
>>>>>>>
>>>>>>>> Sorry if this has been asked many times before....
>>>>>>>>
>>>>>>>> We develop ASP-Webservice code, which runs better than perfect
>>>>>>>> on Mono.
>>>>>>>>
>>>>>>>> On our development system, we want the Webservice Discovery
>>>>>>>> turned on.
>>>>>>>>
>>>>>>>> On our live systems, we want it optionally turned on.
>>>>>>>>
>>>>>>>> The only way I know of doing this is to edit the Web.config file.
>>>>>>>>
>>>>>>>> But this is messy, if done badly can crash the webservice, it
>>>>>>>> has to be
>>>>>>>> done on every release and every time we want to toggle this option.
>>>>>>>>
>>>>>>>> Do any of your members know a simple and elegant method for
>>>>>>>> toggling the
>>>>>>>> Webservice Discovery visibility?
>>>>>>>>
>>>>>>>> Thanks for your help,
>>>>>>>>
>>>>>>>> Ben.
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Mono-list maillist - Mono-list at lists.ximian.com
>>>>>>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>>>>>
>>>>>>
>>>>>
>>>>
>>> using System.Web;
>>> using System.Web.Services.Discovery;
>>>
>>> namespace MyNamespace
>>> {
>>> public class OptionalDiscoveryRequestHandler : IHttpHandler
>>> {
>>> internal static bool EnableDiscovery;
>>>
>>> public OptionalDiscoveryRequestHandler()
>>> {
>>> }
>>>
>>> public void ProcessRequest(HttpContext context)
>>> {
>>> if (!EnableDiscovery)
>>> throw new HttpException(403, "Forbidden");
>>>
>>> new DiscoveryRequestHandler().ProcessRequest(context);
>>> }
>>>
>>> public bool IsReusable
>>> {
>>> get
>>> {
>>> return true;
>>> }
>>> }
>>> }
>>> }
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Mono-list maillist - Mono-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>
> using System.Web;
> using System.Web.Services.Protocols;
>
> namespace MyNamespace
> {
> public class OptionalDocumentationRequestHandlerFactory :
> IHttpHandlerFactory
> {
> private class DocumentationForbiddenHandler : IHttpHandler
> {
> public DocumentationForbiddenHandler()
> {
> }
>
> public void ProcessRequest(HttpContext context)
> {
> throw new HttpException(403, "Forbidden");
> }
>
> public bool IsReusable
> {
> get
> {
> return true;
> }
> }
> }
>
> internal static bool EnableDocumentation;
>
> private WebServiceHandlerFactory webServiceHandlerFactory;
>
> public OptionalDocumentationRequestHandlerFactory()
> {
> webServiceHandlerFactory = new WebServiceHandlerFactory();
> }
>
> public IHttpHandler GetHandler(HttpContext context, string verb,
> string url, string filePath)
> {
> string pathInfo = context.Request.PathInfo;
>
> if (!EnableDocumentation && verb == "GET" && (pathInfo ==
> null || pathInfo.Length == 0))
> return new DocumentationForbiddenHandler();
>
> return webServiceHandlerFactory.GetHandler(context, verb,
> url, filePath);
> }
>
> public void ReleaseHandler(IHttpHandler handler)
> {
> if (!(handler is DocumentationForbiddenHandler))
> webServiceHandlerFactory.ReleaseHandler(handler);
> }
> }
> }
More information about the Mono-list
mailing list