cancel
Showing results for 
Search instead for 
Did you mean: 

Using alf_method to simulate POST

sigpaolo
Champ in-the-making
Champ in-the-making
I developed an application using webscripts in Alfresco 3.4. To reduce the number of webscripts often i declared webscripts supporting POST but i called them also with a GET using the parameter alf_method.

http://....../wcsevice/...?alf_method=POST&param1=….

Also indicated in this post
https://forums.alfresco.com/en/viewtopic.php?f=36&t=25633#p83399

In Alfresco 4.0 seems that these feature is no longer available. The wiki page of webscripts report that these feature (tunneling) is available only for POST call.

Looking into spring framework extension source code version 1.0.0 included in Alfresco I found the problem.
Class org.springframework.extensions.webscripts.servlet.WebScriptServletRuntime


protected String getScriptMethod()
    {
        String method = req.getMethod();
        if(method.equalsIgnoreCase("post"))
        {
            boolean overloadParam = false;
            String overload = req.getHeader("X-HTTP-Method-Override");
            if(overload == null || overload.length() == 0)
            {
                overload = req.getParameter("alf_method");
                overloadParam = true;
            }
            if(overload != null && overload.length() > 0)
            {
                if(logger.isDebugEnabled())
                    logger.debug((new StringBuilder()).append("POST is tunnelling method '").append(overload).append("' as specified by ").append(overloadParam ? "alf_method parameter" : "X-HTTP-Method-Override header").toString());
                method = overload;
            }
        }
        return method;
    }

The problem is the if that check only the post method

Looking last release RC1 on subversion the "if" statement is


    if (method.equalsIgnoreCase("get") || method.equalsIgnoreCase("post"))

Thanks
Paolo
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

the GET-support was previously only included for testing purposes and seems to have been removed deliberately (explicit wiki change by KevinR).
I do not quite understand your need to use the tunneling approach - is it for convenience or to circumvent something strange in your environment? Both due to potential URL length limitations of software components and sideeffects due to GET request caching, I'd advise against using GET for HTTP tunneling in a production application. It is also not really needed for testing purposes, as there are various testing tools far better suited than your browser address bar.

Regards
Axel

bkalbfus
Champ in-the-making
Champ in-the-making
The purpose of alf_method and x-http-method-override header is to overcome client limitations.  I found this post when I was looking for a work-around for Crystal Report's limitation to HTTP GET when consuming xml via http without SOAP.  I'm looking to run a CMIS query this way.  I hope they put this back;  Crystal Reports is still widely used.