Web script cannot be called from Share if name end with '/'
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2014 11:05 AM
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:
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
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
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2014 12:48 AM
In share url as "Alfresco.constants.PROXY_URI***" will be submited to a spring mvc controller which is class
That means your
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.