You
can use the Apache Axis WSDL2Java tool to convert a service WSDL
into Java proxy classes so that you can invoke service operations.
Using Apache Ant, you can generate Axis library files from a LiveCycle service WSDL that lets you invoke the service. (See Creating Java proxy classes using Apache Axis.)
The Apache Axis WSDL2Java tool generates JAVA files that contain
methods that are used to send SOAP requests to a service. SOAP requests
received by a service are decoded by the Axis-generated libraries
and turned back into the methods and arguments.
Create Java proxy classes that consume the MyApplication/EncryptDocument service
WSDL using Apache Axis. (See Creating Java proxy classes using Apache Axis.)
Include the Java proxy classes into your class path.
Create a MyApplicationEncryptDocumentServiceLocator object by
using its constructor.
Create a URL object by using its constructor
and passing a string value that specifies the LiveCycle service WSDL definition. Ensure that you specify ?blob=dime at
the end of the SOAP endpoint URL. For example, use
http://hiro-xp:8080/soap/services/MyApplication/EncryptDocument?blob=dime.
Create an EncryptDocumentSoapBindingStub object
by invoking its constructor and passing the MyApplicationEncryptDocumentServiceLocator object
and the URL object.
Set the LiveCycle user name and password value by
invoking the EncryptDocumentSoapBindingStub object’s setUsername and setPassword methods.
encryptionClientStub.setUsername("administrator");
encryptionClientStub.setPassword("password");
Retrieve the PDF document to send to the MyApplication/EncryptDocument service
by creating a java.io.File object. Pass a string
value that specifies the PDF document location.
Create a javax.activation.DataHandler object
by using its constructor and passing a javax.activation.FileDataSource object.
The javax.activation.FileDataSource object can
be created by using its constructor and passing the java.io.File object
that represents the PDF document.
Create an org.apache.axis.attachments.AttachmentPart object
by using its constructor and passing the javax.activation.DataHandler object.
Attach the attachment by invoking the EncryptDocumentSoapBindingStub object’s addAttachment method
and passing the org.apache.axis.attachments.AttachmentPart object.
Create a BLOB object by using its constructor.
Populate the BLOB object with the attachment identifier
value by invoking the BLOB object’s setAttachmentID method
and passing the attachment identifier value. This value can be obtained
by invoking the org.apache.axis.attachments.AttachmentPart object’s getContentId method.
Invoke the MyApplication/EncryptDocument process
by invoking the EncryptDocumentSoapBindingStub object’s invoke method.
Pass the BLOB object that contains the DIME attachment.
This process returns an encrypted PDF document within a BLOB object.
Obtain the attachment identifier value by invoking the returned BLOB object’s getAttachmentID method.
This method returns a string value that represents the identifier
value of the returned attachment.
Retrieve the attachments by invoking the EncryptDocumentSoapBindingStub object’s getAttachments method.
This method returns an array of Objects that represent
the attachments.
Iterate through the attachments (the Object array)
and use the attachment identifier value to obtain the encrypted
PDF document. Each element is an org.apache.axis.attachments.AttachmentPart object.
Obtain the javax.activation.DataHandler object
associated with the attachment by invoking the org.apache.axis.attachments.AttachmentPart object’s getDataHandler method.
Obtain a java.io.FileStream object by invoking
the javax.activation.DataHandler object’s getInputStream method.
Create a byte array and pass that byte array to the java.io.FileStream object’s read method.
This method populates the byte array with a data stream that represents
the encrypted PDF document.
Create a java.io.File object by using its
constructor. This object represents the encrypted PDF document.
Create a java.io.FileOutputStream object
by using its constructor and passing the java.io.File object.
Invoke the java.io.FileOutputStream object’s write method
and pass the byte array that contains the data stream that represents
the encrypted PDF document.