rif6894 - Friday, September 16, 2011 9:40 PM:
I have used the code in topic www.aras.comhttp:/.../1974.aspx to create a Document and upload the corresponding file - not a problem.
But the Document object is left in a 'locked' state, which I wish to remove using java with SOAP. Java is the language of choice as the source documents exist on a soon to be retired Solaris server.
The following code works within NASH
<AML>
<ApplyItem>
<Item type='Document' id='76126C1815DA441B80E11492ACF437A4' action='unlock'>
</Item>
</ApplyItem>
</AML>
But the following does not work within Java.
import java.net.*;
import java.io.*;
import java.security.*;
import java.math.*;
class filecheckin1
{
public static String calcMD5(String s) {
MessageDigest m = null;
try {
m=MessageDigest.getInstance("MD5");
m.update(s.getBytes(),0,s.length());
}
catch (NoSuchAlgorithmException e) {
System.err.println("Invalid algorithm");
System.exit(-1);
}
return (new BigInteger(1,m.digest()).toString(16));
}
public static void main(String args[])
{
try {
URL u = new URL("localhost/.../vaultServer.aspx");
URLConnection uc = u.openConnection();
HttpURLConnection connection = (HttpURLConnection) uc;
String boundary = "-------------------------BRdnIy5hBONlyI";
String docPath = "C:\etihad.pdf";
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary="+boundary);
OutputStream os = connection.getOutputStream();
File file = new File(docPath);
FileInputStream is = new FileInputStream(file);
String content = "--"+boundary +"
Content-Disposition: form-data; name="SOAPACTION";
Content-Type: text/plain
ApplyItem
";
os.write(content.getBytes());
content = "--"+boundary +"
Content-Disposition: form-data; name="AUTHUSER";
Content-Type: text/plain
admin
";
os.write(content.getBytes());
content = "--"+boundary +"
Content-Disposition: form-data; name="AUTHPASSWORD";
Content-Type: text/plain
"+calcMD5("innovator")+"
";
os.write(content.getBytes());
content = "--"+boundary +"
Content-Disposition: form-data; name="DATABASE";
Content-Type: text/plain
InnovatorSolutions
";
os.write(content.getBytes());
content = "--"+boundary +"
Content-Disposition: form-data; name="XMLDATA";
Content-Type: text/plain
";
content += "<SOAP-ENV:Envelope xmlns:SOAP-ENV='schemas.xmlsoap.org/.../'>";
content += " <SOAP-ENV:Body>";
content += " <ApplyItem>";
content += " <Item type='Document' id='76126C1815DA441B80E11492ACF437A4' action='unlock'>";
content += " </Item>";
content += " </ApplyItem>";
content += " </SOAP-ENV:Body>";
content += "</SOAP-ENV:Envelope>
";
os.write(content.getBytes());
os.flush();
os.close();
InputStream in = connection.getInputStream();
int c;
while ((c = in.read()) != -1) System.out.write(c);
in.close();
}
catch (IOException e) {
System.err.println(e);
}
}
}
Any suggestions on how to unlock an object?
rif6894 - Wednesday, December 14, 2011 5:18 PM:
Appropriate use of 'edit' action allowed the correct lock/unlock functionality