Hi folks,Happy holidays to all.I am trying to write a webscript that accepts formdata from a form. The webapp sending the form, however, uses a commons-httpclient proxy to do authentication and to separate the alfresco instance from the web application.I can't seem to get the web script to accept any arguments. Here is an excerpt from the webscript code:
script:
{
var authorEmail = null;
var content = null;
var comment = null;
for (arg in args)
{
logger.log(arg + "=" + args[arg]);
}
// log each argument (assuming one or more values have been provided for each)
for (arg in argsM)
{
for each (val in argsM[arg])
{
logger.log(arg + "=" + val);
}
}
// locate file attributes
for each (field in formdata.fields)
{
if (logger.isLoggingEnabled()) {
logger.log("found field "+field.name+" with value "+field.value);
}
if (field.name == "email")
{
authorEmail = field.value;
}
else if (field.name == "comment")
{
content = field.value;
}
}
if (logger.isLoggingEnabled()) {
// logger.log("formdata is +"formdata.fields);
logger.log("email is "+authorEmail);
logger.log("content is "+content);
}
As you can see, this excerpt simply tries to display parameters submitted, and the only output isemail is nullcontent is nullThe commons-http client excerpt is below:
client.getHttpConnectionManager().getParams()
.setConnectionTimeout(5000);
client.getState().setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
PostMethod post = new PostMethod(url);
post.setDoAuthentication(true);
post.setRequestHeader("Content-Type", "multipart/form-data");
Part[] parts = { new StringPart("email", authorEmail),
new StringPart("comment", comment) };
post.setRequestEntity(new MultipartRequestEntity(parts, post
.getParams()));
try {
int status = client.executeMethod(post);
System.out.println("received status " + status);
if (status > 299) { // there was an error
System.out.println(post.getResponseBodyAsString());
}
} finally {
post.releaseConnection();
}
}
I've also tried to send data using NameValuePairs and the setRequestBody () method, to no avail. I know that the Content-Type is set correctly because if I change it or remove it, the formdata object is never initialized in the script.Any ideas?Dan