-
Create Java proxy classes using JAX-WS that consumes
the
MyApplication/EncryptDocument
service WSDL.
Use the following WSDL endpoint:
http://hiro-xp:8080/soap/services/MyApplication/EncryptDocument?WSDL&lc_version=9.0.1
For
information, see
Creating Java proxy classes using JAX-WS
.
Note:
Replace
hiro-xp
with the IP address of the J2EE application server hosting LiveCycle.
-
Package the Java proxy classes created using using JAX-WS
into a JAR file.
-
Include the Java proxy JAR file and the JAR files located
in the following path:
<Install Directory>\Adobe\Adobe_Experience_Manager_forms\sdk\client-libs\thirdparty
into your Java client project’s class
path.
-
Create a
MyApplicationEncryptDocumentService
object
by using its constructor.
-
Create a
MyApplicationEncryptDocument
object
by invoking the
MyApplicationEncryptDocumentService
object’s
getEncryptDocument
method.
-
Set the connection values required to invoke LiveCycle by assigning values to the following data members:
-
Assign the WSDL endpoint and the encoding type to the
javax.xml.ws.BindingProvider
object’s
ENDPOINT_ADDRESS_PROPERTY
field.
To invoke the
MyApplication/EncryptDocument
service
using SwaRef encoding, specify the following URL value:
http://hiro-xp:8080/soap/services/MyApplication/EncryptDocument?blob=swaref
-
Assign the AEM forms user to the
javax.xml.ws.BindingProvider
object’s
USERNAME_PROPERTY
field.
-
Assign the corresponding password value to the
javax.xml.ws.BindingProvider
object’s
PASSWORD_PROPERTY
field.
The
following code example shows this application logic:
//Set connection values required to invoke LiveCycle
String url = "http://hiro-xp:8080/soap/services/MyApplication/EncryptDocument?blob=swaref";
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);
-
Retrieve the PDF document to send to the
MyApplication/EncryptDocument
process
by creating a
java.io.File
object by using its
constructor. Pass a string value that specifies the location of
the PDF document.
-
Create a
javax.activation.DataSource
object
by using the
FileDataSource
constructor. Pass the
java.io.File
object.
-
Create a
javax.activation.DataHandler
object
by using its constructor and passing the
javax.activation.DataSource
object.
-
Create a
BLOB
object by using its constructor.
-
Populate the
BLOB
object by invoking its
setSwaRef
method
and passing the
javax.activation.DataHandler
object.
-
Invoke the
MyApplication/EncryptDocument
process
by invoking the
MyApplicationEncryptDocument
object’s
invoke
method
and passing the
BLOB
object that contains the PDF
document. The invoke method returns a
BLOB
object
that contains an encrypted PDF document.
-
Populate a
javax.activation.DataHandler
object
by invoking the
BLOB
object’s
getSwaRef
method.
-
Convert the
javax.activation.DataHandler
object
to a
java.io.InputSteam
instance by invoking the
javax.activation.DataHandler
object’s
getInputStream
method.
-
Write the
java.io.InputSteam
instance to
a PDF file that represents the encrypted PDF document.