cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using login ticket

rexmao
Champ in-the-making
Champ in-the-making
Hi, freinds

   I'm learning the Alfresco web scripts api. I called the login api to get a alf_ticket string (TICKET_60af92a1ae009fd39fd121fc871eab9b966070c5). I appended this string to the url which calls the api getChilden. Everything's smoothly and I got the return results. But when I called the method which uses http POST method, for example the file upload api. The login dialog poped up.

Does any one know the authentication method used for the api in http POST method? I don't want the end user to see the login dialog.

Thanks in advance
3 REPLIES 3

gyro_gearless
Champ in-the-making
Champ in-the-making
Hi,

Basically, this should work, so what is the exact URL by which you invoke your webscript? And how is security configured in your xyz.put.desc.xml?

Cheers
Gyro

rexmao
Champ in-the-making
Champ in-the-making
Hi Gyro,

Thanks for you response.

Actually, I wrote a script for file uploading based on the example. I paste the code below:

BTW, I call this script in another .net application. Before file uploading, the .net app calls the authenticaiton script to get the ticket and the appends the ticket string to the uploading url. Only the first time, end users need to input the username & password in the popup dialog. But I don't want them to do this even only one time.

upload.post.desc.xml
<webscript>
  <shortname>File Upload Sample</shortname>
  <description>Upload file content and meta-data into Repository</description>
  <url>/sample/upload</url>
  <authentication>user</authentication>
</webscript>

upload.post.js
var filename=null;
var content=null;
var title="";
var description="";
var uploadpath="";
var scajxh;
var scbgqx;
var scflbm;
var schgzh;
var schth;
var scjhao;
var scmiji;
var scqzh;

// locate file attributes
var field;
for each (field in formdata.fields)
{
  if (field.name=="title")
  {
    title=field.value;
  }
  else if (field.name=="desc")
  {
    description=field.value;
  }
  else if (field.name=="file" && field.isFile)
  {
    filename=field.filename;
    content=field.content;
  }
  else if (field.name=="uploadpath")
  {
    uploadpath = field.value;
  }
  else if (field.name=="scajxh")
  {
    scajxh = field.value;
  }
  else if (field.name=="scbgqx")
  {
    scbgqx = field.value;
  }
  else if (field.name=="scflbm")
  {
    scflbm = field.value;
  }
  else if (field.name=="schgzh")
  {
    schgzh = field.value;
  }
  else if (field.name=="schth")
  {
    schth = field.value;
  }
else if (field.name=="scjhao")
  {
    scjhao = field.value;
  }
else if (field.name=="scmiji")
  {
    scmiji = field.value;
  }
else if (field.name=="scqzh")
  {
    scqzh = field.value;
  }
}

// ensure mandatory file attributes have been located
if (filename==undefined || content == undefined)
{
  status.code = 400;
  status.message = "Uploaded file cannot be located in request";
  status.redirect = true;
}
else
{
  // create document in company home for uploaded file
 
  if (uploadpath==null||uploadpath==undefined||uploadpath==""){
   //upload = companyhome.createFile(filename) ;
upload = companyhome.createNode(filename,"sc:equipment");
  }
  else {
  upload = companyhome.childByNamePath(uploadpath).createNode(filename,"sc:equipment") ;
  }
 
  upload.properties.content.write(content);
  upload.properties.encoding = "UTF-8";
  upload.properties.title = title;
  upload.properties.description = description;
  if (scajxh!=null&&scajxh!=undefined&&scajxh!=""){
  upload.properties["sc:ajxh"]=scajxh;
  }
  if (scbgqx!=null&&scbgqx!=undefined&&scbgqx!=""){
      upload.properties["sc:bgqx"]=new Date(scbgqx);
  }
  if (scflbm!=null&&scflbm!=undefined&&scflbm!=""){
  upload.properties["sc:flbm"]=scflbm;
  }
  if (schgzh!=null&&schgzh!=undefined&&schgzh!=""){
  upload.properties["sc:hgzh"]=schgzh;
  }
  if (schth!=null&&schth!=undefined&&schth!=""){
  upload.properties["sc:schth"]=schth;
  }
  if (scjhao!=null&&scjhao!=undefined&&scjhao!=""){
  upload.properties["sc:jhao"]=scjhao;
  }
  if (scmiji!=null&&scmiji!=undefined&&scmiji!=""){
  upload.properties["sc:miji"]=scmiji;
  }
  if (scqzh!=null&&scqzh!=undefined&&scqzh!=""){
  upload.properties["sc:qzh"]=scqzh;
  }

  upload.save();

  // setup model for response template
  model.upload = upload;
}

gyro_gearless
Champ in-the-making
Champ in-the-making
So can you trace how exactly your app is invoking the webscript? I.e., with all parameters and responses from Alfresco?
Here is an example from some client application, which uses a webscript POST to do some post-processing on imported documents:

http://cmqa02.acme-corp.de:8080/alfresco/service/de/acme-corp/set-creator?nodeRef=workspace%3A%2F%2F...

(Domain name obfuscated to protect the innocent)

BTW, i found Membrane Soap Monitor an invaluable tool for tracing HTTP interrogations - despite its name, it also an useful general purpose HTTP monitor 🙂

–> http://www.membrane-soa.org/soap-monitor/