cancel
Showing results for 
Search instead for 
Did you mean: 

how to create and register webscript

pmarreddy
Champ in-the-making
Champ in-the-making
hi,

i am trying to create a web script in folder
/Company Home/Data Dictionary/Web Scripts/org/alfresco/sample

and my

swsearch.get.desc.xml

<webscript>
<shortname>sw Search</shortname>
<description> search term</description>
<url>/sw/swsearch</url>
<format default="html">extension</format>
<authentication>guest</authentication>
<transaction>required</transaction>
</webscript>


swsearch.get.html.ftl

<html>
<body>
<img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" />
Blog query: ${args.q}
<br>
<table>
<#list resultset as node>
<tr>
<td><img src="${url.context}${node.icon16}"/>
<td><a href="${url.serviceContext}/api/node/content/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/${node.name?url}">${node.name}</a>
</tr>
</#list>
</table>
</body>
</html>

swsearch.get.js


// check that search term has been provided
if (args.q == undefined || args.q.length == 0)
{
status.code = 400;
status.message = "Search term has not been provided.";
status.redirect = true;
}
else
{
// perform search
var nodes = search.luceneSearch( "(TYPE:\"{http://www.mydomain.com/model/pariksha/1.0}quiz\") AND (@pk\\:tags:\""+args.q +"\")");
model.resultset = nodes;
}



i dont know what i amdoing wron but when i try http://localhost:8080/alfresco/service/sw/swsearch

i am getting Script url /sw/swsearch does not map to a Web Script.

thanks prasanth
3 REPLIES 3

pmarreddy
Champ in-the-making
Champ in-the-making
it turns out i just need to restrat the server.

davidc
Star Contributor
Star Contributor
You don't have to restart the server.

Go to the URL:

/alfresco/service/
and hit the "Refresh list of Web Scripts" button.  Your webscript will be registered.

Also, a tip for dumping the contents of your web script to the forum.  There's the URL /alfresco/service/script/{scriptid} which will dump everything about your web script, including the implementation files.  This can be paste to the forum.

e.g.

/alfresco/service/org/alfresco/sample/swsearch.get

pmarreddy
Champ in-the-making
Champ in-the-making
thanks david.