The following Java code example invokes a process named MyApplication/EncryptDocument using
data over HTTP. (See Invoking LiveCycle using BLOB data over HTTP.)
An unsecured PDF document based on a PDF file named Loan.pdf is
passed to the LiveCycle process using SOAP over HTTP. The PDF file
is located at the following URL: http://hiro-xp:8080/FormsQS.
The process returns a password-encrypted PDF document that is saved
as a PDF file named EncryptedDocument.pdf.
/**
* Ensure that you create Java proxy files that consume
* the the LiveCycle service WSDL. You can use JAX-WS to create
* the Java proxy files.
*
* This Java quick start uses BLOB over HTTP to invoke a short-lived process named
* EncryptDocument. For information, see
* "Invoking LiveCycle using BLOB over HTTP" in Programming with LiveCycle.
*/
import java.io.*;
import java.net.URL;
import javax.xml.ws.BindingProvider;
import com.adobe.idp.services.*;
public class InvokeEncryptDocumentHTTP {
public static void main(String[] args){
try{
//Create a MyApplicationEncryptDocument object
MyApplicationEncryptDocumentService encClient = new MyApplicationEncryptDocumentService();
MyApplicationEncryptDocument encryptDocClient = encClient.getEncryptDocument();
//Set connection values required to invoke LiveCycle using BLOB over HTTP
String url = "http://hiro-xp:8080/soap/services/MyApplication/EncryptDocument?blob=http";
String username = "administrator";
String password = "password";
((BindingProvider) encryptDocClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
((BindingProvider) encryptDocClient).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
((BindingProvider) encryptDocClient).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
//Create a BLOB object and populate it by invoking the setRemoteURL method
BLOB inDoc = new BLOB();
inDoc.setRemoteURL("http://hiro-xp:8080/FormsQS/Loan.pdf");
//invoke the short-lived process named MyApplication/EncryptDocument
BLOB outDoc = encryptDocClient.invoke(inDoc);
//Retrieve an InputStream from the returned BLOB instance
URL myURL = new URL(outDoc.getRemoteURL());
InputStream inputStream = myURL.openStream();
//Create a new file containing the returned PDF document
File f = new File("C:\\Adobe\EncryptedDocument.pdf");
OutputStream out = new FileOutputStream(f);
//Iterate through the buffer
byte buf[] = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0)
out.write(buf, 0, len);
out.close();
inputStream.close();
System.out.println("The short-lived process named EncryptDocument was successfully invoked.");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
|
|
|