cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco POST Examples?

nm_santos
Champ in-the-making
Champ in-the-making
Hi,

I've been trying to search for POST web scripts examples, but I couldn't find any.

I'm interest in sending an HTTP POST Message with an xml in the body, to a script in alfresco (in Java).

Can anyone point me to some documentation?

My problem resides in obtaining the xml file in the script, I don't know how.

Regards,
Nuno Santos.
4 REPLIES 4

abarisone
Star Contributor
Star Contributor
Hi,
you can start from here http://localhost:8080/alfresco/service/index
You can browse all Alfresco registered webscripts on your Alfresco installation, for example by package, and find the corresponding implementation.
You may find there some hints about what you are trying to do.

Regards,
Andrea

loftux
Star Contributor
Star Contributor
Once you get the uploaded file, you can parse it using the built in xml object
https://developer.mozilla.org/en/E4X
i.e. something like
myfile = new XML(xmlfile);
currentvalue = myfile.elementtoget.toString();

nm_santos
Champ in-the-making
Champ in-the-making
Hi,

Thanks for the replies.

Here's what I have so far:

public class JavaFileUpload extends DeclarativeWebScript{
   
   
   protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
   {
      String content = null;
      try {
         content = req.getContent().getContent();
         
      } catch (IOException e) {
         
         e.printStackTrace();
      }
            
      Map<String, Object> model = new HashMap<String, Object>();
      model.put("content:", content);
      
      return model;
      
   }
   

}

For now it is just a test, so that I know it works.

Now, how can I configure the .ftl file?

I've read http://localhost:8080/alfresco/service/script/org/alfresco/repository/upload/upload.post, but sill I don't know how I can render the response.

Regards,
Nuno.

abarisone
Star Contributor
Star Contributor
Hi Nuno,
you'd better first take a look at these links in order to get acquainted with freemarker templates…
http://wiki.alfresco.com/wiki/FreeMarker_Template_Cookbook
http://wiki.alfresco.com/wiki/Template_Guide
http://freemarker.sourceforge.net/docs/index.html

Regards