Invoking LiveCycle using SwaRef

You can invoke LiveCycle services using SwaRef. The content of the wsi:swaRef XML element is sent as an attachment inside a SOAP body that stores the reference to the attachment. When invoking a LiveCycle service by using SwaRef, create Java proxy classes by using the Java API for XML Web Services (JAX-WS). (See Java API for XML Web Services .)

The discussion here is about invoking the following LiveCycle short-lived process named MyApplication/EncryptDocument by using SwaRef.

Note: This process is not based on an existing LiveCycle process. To follow along with the code example, create a process named MyApplication/EncryptDocument using Workbench. (See Using Workbench .)

When this process is invoked, it performs the following actions:

  1. Obtains the unsecured PDF document that is passed to the process. This action is based on the SetValue operation. The input parameter for this process is a document process variable named inDoc .

  2. Encrypts the PDF document with a password. This action is based on the PasswordEncryptPDF operation. The password encrypted PDF document is returned in a process variable named outDoc .

Note: SwaRef support added in LiveCycle, version 9.

The discussion below is about how to invoke LiveCycle services by using SwaRef within a Java client application. The Java application uses proxy classes created by using JAX-WS.

Invoke a service using JAX-WS library files that use SwaRef

To invoke the MyApplication/EncryptDocument process by using Java proxy files created using JAX-WS and SwaRef, perform the following steps:

  1. 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.
  2. Package the Java proxy classes created using using JAX-WS into a JAR file.

  3. 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.

  4. Create a MyApplicationEncryptDocumentService object by using its constructor.

  5. Create a MyApplicationEncryptDocument object by invoking the MyApplicationEncryptDocumentService object’s getEncryptDocument method.

  6. 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);
  7. 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.

  8. Create a javax.activation.DataSource object by using the FileDataSource constructor. Pass the java.io.File object.

  9. Create a javax.activation.DataHandler object by using its constructor and passing the javax.activation.DataSource object.

  10. Create a BLOB object by using its constructor.

  11. Populate the BLOB object by invoking its setSwaRef method and passing the javax.activation.DataHandler object.

  12. 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.

  13. Populate a javax.activation.DataHandler object by invoking the BLOB object’s getSwaRef method.

  14. Convert the javax.activation.DataHandler object to a java.io.InputSteam instance by invoking the javax.activation.DataHandler object’s getInputStream method.

  15. Write the java.io.InputSteam instance to a PDF file that represents the encrypted PDF document.

Note: Most LiveCycle service operations have a SwaRef quick start. You can view these quick starts in a service’s corresponding quick start section. For example, to see the Output quick start section, see Output Service API Quick Starts .

// Ethnio survey code removed