cancel
Showing results for 
Search instead for 
Did you mean: 

Web script cannot be called from Share if name end with '/'

sunquanbin
Champ on-the-rise
Champ on-the-rise
Hi,

I've got a quite strange issue which is the Webscript defined in Alfresco cannot be called from Share if it ends with "/" in its url tag.

To be more specific, I have defined an Alfresco side web service "mytest"(defined as <url>/mytest/</url>) which is working when I access it with the url: http://localhost:8080/alfresco/service/mytest/.

So in share (in client js), The following should work:

                    $.ajax({
                        url: Alfresco.constants.PROXY_URI + "mytest/",
                        type: "GET",
                        contentType: 'application/json',
                        success: function TestAjaxCall(response) {
                            console.log(response);
                        },
                        error: function test_error(response) {
                            console.log(response);
                        }
                    });


What I get now is a 404 says: mytest/ does not map to a Web Script.

I then noticed that if I change the url in desc.xml from "<url>/mytest/</url>" to "<url>/mytest</url>", the web service will work in both Alfresco and Share. It looks like the suffixed "/" has caused the problem.

Does anyone know the reason?

Many Thanks,

Sun 
1 REPLY 1

kaynezhang
World-Class Innovator
World-Class Innovator
In share url as "Alfresco.constants.PROXY_URI***" will be submited to a spring mvc controller which is class
org.springframework.extensions.webscripts.servlet.mvc.EndPointProxyController
,in this controller class the request url is rebuild for data webscript request, during the rebuilding process ,the ending slash will be removed.
That means your
 url: Alfresco.constants.PROXY_URI + "mytest/"
will be submited to
http://localhost:8080/alfresco/service/mytest
,which can't be found( in your desc.xml url is setted to "/mytest/") ,so changing "/mytest/" to "/mytest" will work.