AnsweredAssumed Answered

Java Backed Webscript problem in

Question asked by nagababu on Apr 22, 2013
Latest reply on Apr 22, 2013 by mitpatoliya

I created execute script rule in alfresco and I kept my javascript file in Company Home>Data Dictionary>script folder.

My Rule is as follows:

All Items > Executes script 'dataFilesScript.js' > Items are created or entered this folder >Finish 

1). My Js script is as follows.

var simplehttpresult = "";

try {
   simplehttpresult = SimpleHttpConnection.getContentAsString("");
   error = String(ex)

2).I add following lines in web-scripts-application-context.xml

<bean id=""
     <property name="repository" ref="repositoryHelper" />
      <property name="serviceRegistry" ref="ServiceRegistry" />


3).My simple.get.desc.xml file

  <shortname>The World's Simplest Webscript</shortname>
  <description>Hands back a little bit of JSON</description>
  <format default="">argument</format>
  <family>Alfresco Java-Backed WebScripts Demo</family>

4). I add following lines script-services-context.xml

<bean id="httpUtilsScript" parent="baseJavaScriptExtension"
        <property name="extensionName">

5).My Java file is as follows.

public class SimpleWebScript extends AbstractWebScript
    public void execute(WebScriptRequest req, WebScriptResponse res)
        throws IOException
          // build a json object
          JSONObject obj = new JSONObject();
          // put some data on it
          obj.put("field1", "data1");
          // build a JSON string and send it back
          String jsonString = obj.toString();
       catch(JSONException e)
          throw new WebScriptException("Unable to serialize JSON");

When my rule is executed. It's working fine in Alfresco 4.0 but it is not working in other versions such as 4.1.3, 4.2.a, 4.2.c…
In Alfresco 4.2.C My action code is calling only once when the service is started. When the rule is executed second time onwords Java backed code is not executing. Is it required to do any other configuration settings in alfresco versions beyond 4.0.

Please suggest…..

Thanks In Advance.