cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED]what's wrong with this webscript?

targa2000
Champ in-the-making
Champ in-the-making
I can run this webscript without problem, added to Data Dictionary\Web Scripts Extensions via the Add Content button:

simple.get.desc.xml
<webscript>
<shortname>Simple</shortname>
<description>Simple web script</description>
<url>/simple?name={nameArgument}</url>
</webscript>

simple.get.html.ftl
<html>
<body>
<p>Simple, ${args.name}!</p>
</body>
</html>

but the following webscript either doesn't run or returns a WebScriptException: Transaction must be active and synchronization is required

helloworld.get.desc.xml
<webscript>
<shortname>Hello World</shortname>
<description>Hello world web script</description>
<url>/helloworld?name={nameArgument}</url>
</webscript>

helloworld.get.html.ftl
<html>
<body>
<p>Hello, ${args.name}!</p>
<p>Foo: ${foo}</p>
</body>
</html>

helloworld.get.js
model.foo = "bar";

What is wrong with the second webscript? running on Alfresco EE 3.2 on Windows Vista
6 REPLIES 6

targa2000
Champ in-the-making
Champ in-the-making
tried these webscripts on two different Alfresco EE 3.2 installations, one vista, one xp, same results

mikeh
Star Contributor
Star Contributor
Try adding
<transaction allow="readonly">required</transaction>
to the webscript descriptor (.desc.xml)

Thanks,
Mike

targa2000
Champ in-the-making
Champ in-the-making
Hi Mike,

Thanks for the suggestion, but added the line and calling the webscript with

http://localhost:8080/alfresco/service/helloworld?name=Steve

now I receive:

Web Script Status 500 - Internal Error

500 Description: An error inside the HTTP server which prevented it from fulfilling the request.
 
Message: 01160002 Wrapped Exception (with status template): A valid SecureContext was not provided in the RequestContext
  
Exception: net.sf.acegisecurity.AuthenticationCredentialsNotFoundException - A valid SecureContext was not provided in the RequestContext
  
Exception: org.alfresco.web.scripts.WebScriptException - 01160002 Wrapped Exception (with status template): A valid SecureContext was not provided in the RequestContext
  
Exception: org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)
  
Server: Alfresco Enterprise v3.2.0 (304) schema 3.400

any suggestions?

targa2000
Champ in-the-making
Champ in-the-making
Also tried:

<webscript>
<shortname>Hello World</shortname>
<description>Hello world web script</description>
<url>/helloworld?name={nameArgument}</url>
<transaction allow="readonly">required</transaction>
<authentication>none</authentication>
</webscript>

but still get:

The Web Script /alfresco/service/helloworld  has responded with a status of 500 - Internal Error.

500 Description:   An error inside the HTTP server which prevented it from fulfilling the request.

Message:   01160010 Wrapped Exception (with status template): A valid SecureContext was not provided in the RequestContext
   
Exception:   net.sf.acegisecurity.AuthenticationCredentialsNotFoundException - A valid SecureContext was not provided in the RequestContext

targa2000
Champ in-the-making
Champ in-the-making
Okay, this works:

<webscript>
<shortname>Hello World</shortname>
<description>Hello world web script</description>
<url>/helloworld?name={nameArgument}</url>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

mathias_lin
Star Contributor
Star Contributor
The .desc.xml needs the following lines:


<transaction>required</transaction>
<authentication>user</authentication>