Retrieving Content from Content Services (deprecated)

You can programmatically retrieve content from LiveCycle Content Services (deprecated) by using the Java or web service API. You can retrieve a PDF file and pass it to another LiveCycle services operation or save it to the local file system. To retrieve content, you require permission to access the content. That is, if you specify a user who does not have permission to access a file, an exception is thrown.

For more information about the Document Management service, see Services Reference for LiveCycle.

注意: Adobe is migrating Adobe® LiveCycle® Content Services ES customers to the Content Repository built on the modern, modular CRX architecture, acquired during the Adobe acquisition of Day Software. The Content Repository is provided with LiveCycle Foundation and is available as of the LiveCycle ES4 release.

Summary of steps

To retrieve content from Content Services (deprecated), follow these steps:

  1. Include project files.

  2. Create the service client.

  3. Specify the content to retrieve.

  4. Save the content to the local file system.

Include project files

Include the necessary files in your development project. If you are using Java to create a client application, include the necessary JAR files. If you are using web services, include the proxy files.

Add the following JAR files to your project’s class path:

  • adobe-livecycle-client.jar

  • adobe-usermanager-client.jar

  • adobe-contentservices-client.jar

  • adobe-utilities.jar (required if LiveCycle is deployed on JBoss)

  • jbossall-client.jar (required if LiveCycle is deployed on JBoss)

注意: These JAR files are required if you are using the EJB connection mode. If you are using the SOAP connection mode, include additional JAR files.

Create the service client

Before you can programmatically retrieve content, establish a connection and provide credentials. This task is accomplished by creating a service client.

Specify the content to retrieve

Invoke the Document Management service’s retrieveContent method to retrieve content. Specify the store name and the fully qualified location of the content to retrieve. If you specify content that does not exist, an exception is thrown.

Save the content to the local file system

After you retrieve content from a specified space, you can save it to the local file system. Then you can view the content. For example, if you save a PDF file, you can open the file in Adobe Reader or Acrobat.

Retrieve content using the Java API

Retrieve content from Content Services (deprecated) by using the Document Management Service API (Java):

  1. Include the project files

    Include client JAR files, such as adobe-contentservices-client.jar, in your Java project’s class path.

  2. Create the service client

    • Create a ServiceClientFactory object that contains Java connection properties.

    • Create a DocumentManagementServiceClientImpl object by using its constructor and passing the ServiceClientFactory object.

  3. Specify the content to retrieve

    Retrieve content by invoking the DocumentManagementServiceClientImpl object’s retrieveContent method and passing the following values:

    • A string value that specifies the store where the content is added. The default store is SpacesStore. This value is a mandatory parameter.

    • A string value that specifies the fully qualified path of the content to retrieve (for example, /Company Home/MortgageForm.pdf). This value is a mandatory parameter.

    • A string value that specifies the version. This value is an optional parameter, and you can pass an empty string. In this situation, the latest version is retrieved.

    The retrieveContent method returns a CRCResult object that contains the content.

  4. Save the content to the local file system

    • Obtain a com.adobe.idp.Document instance that contains the content by invoking the CRCResult object’s getDocument method.

    • Create a java.io.File object and ensure that the file name extension matches the content type. For example, for a PDF document, ensure that the file name extension is .pdf.

    • Invoke the com.adobe.idp.Document object’s copyToFile method to copy the contents of the com.adobe.idp.Document object to the file.

Retrieve content using the web service API

Retrieve content from Content Services (deprecated) by using the Document Management Service API (web service):

  1. Include project files

    Create a Microsoft .NET client project that uses MTOM and consumes the Document Management WSDL.

  2. Create the service client

    • Create a DocumentManagementServiceClient object by using its default constructor.

    • Create a DocumentManagementServiceClient.Endpoint.Address object by using the System.ServiceModel.EndpointAddress constructor. Pass a string value that specifies the WSDL to the LiveCycle service, such as http://localhost:8080/soap/services/DocumentManagementService. You do not need to use the lc_version attribute. This attribute is used when you create a service reference.

    • Create a System.ServiceModel.BasicHttpBinding object by using the value of the DocumentManagementServiceClient.Endpoint.Binding field. Cast the return value to BasicHttpBinding.

    • Set the System.ServiceModel.BasicHttpBinding object’s MessageEncoding field to WSMessageEncoding.Mtom. This value ensures that MTOM is used.

    • Enable basic HTTP authentication by performing the following tasks:

      • Assign the LiveCycle user name to the field DocumentManagementServiceClient.ClientCredentials.UserName.UserName.

      • Assign the corresponding password value to the field DocumentManagementServiceClient.ClientCredentials.UserName.Password.

      • Assign the constant value HttpClientCredentialType.Basic to the field BasicHttpBindingSecurity.Transport.ClientCredentialType.

      • Assign the constant value BasicHttpSecurityMode.TransportCredentialOnly to the field BasicHttpBindingSecurity.Security.Mode.

  3. Specify the content to retrieve

    Retrieve content by invoking the DocumentManagementServiceClient object’s retrieveContent method and passing the following values:

    • A string value that specifies the store where the content is added. The default store is SpacesStore. This value is a mandatory parameter.

    • A string value that specifies the fully qualified path of the content to retrieve (for example, /Company Home/MortgageForm.pdf). This value is a mandatory parameter.

    • A string value that specifies the version. This value is an optional parameter, and you can pass an empty string. In this situation, the latest version is retrieved.

    • A string output parameter that stores the browse link value. The following value is an example of this string output parameter:

      http://10.36.47.100:8080/contentspace/wcs/api/node/content/workspace/SpacesStore/83d76043-51cb-416f-b0aa-911cc05caab4/MortgageForm.pdf

    • A BLOB output parameter that stores the content. You can use this output parameter to obtain the content.

    • A RetrieveContent.ServiceReference1.MyMapOf_xsd_string_To_xsd_anyType output parameter that stores content attributes.

    • A CRCResult output parameter. Instead of using this object, you can use the BLOB output parameter to obtain the content.

  4. Save the content to the local file system

    • Create a System.IO.FileStream object by invoking its constructor. Pass a string value that represents the file location of the PDF document and the mode in which to open the file.

    • Create a byte array that stores the content of the BLOB object that is populated by the retrieveContent method. Populate the byte array by getting the value of the BLOB object’s MTOM field.

    • Create a System.IO.BinaryWriter object by invoking its constructor and passing the System.IO.FileStream object.

    • Write the contents of the byte array to a PDF file by invoking the System.IO.BinaryWriter object’s Write method and passing the byte array.