Quick Start (MTOM): Retrieving credential information using the web service API

The following C# code example retrieves information about the credential that is used to apply usage-rights to a rights-enabled PDF document named LoanUsageRights.pdf. (See Retrieving Credential Information.)

/** 
    * Ensure that you create a .NET project that uses  
    * MS Visual Studio 2008 and version 3.5 of the .NET 
    * framework. This is required to invoke a  
    * LiveCycle service using MTOM. 
    *      
    * For information, see "Invoking LiveCycle using MTOM" in Programming with LiveCycle   
    */ 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.ServiceModel; 
using System.IO; 
using RetrieveCredentialInformation.ServiceReference1; 
 
namespace RetrieveCredentialInformation 
{ 
       class Program 
       { 
           static void Main(string[] args) 
           { 
               try 
               { 
                   //Create a RightsManagementServiceClient object 
                   ReaderExtensionsServiceClient reClient = new ReaderExtensionsServiceClient(); 
                   reClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/ReaderExtensionsService?blob=mtom"); 
 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)reClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   reClient.ClientCredentials.UserName.UserName = "administrator"; 
                   reClient.ClientCredentials.UserName.Password = "password"; 
                   b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
                   b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 
 
                   //Create a BLOB to store a rights-enabled PDF document 
                BLOB inDoc = new BLOB(); 
 
                //Specify a rights-enabled PDF document 
                string path = "C:\\Adobe\LoanUsageRights.pdf"; 
                FileStream fs = new FileStream(path, FileMode.Open); 
 
                //Get the length of the file stream  
                int len = (int)fs.Length;  
                byte[] ByteArray=new byte[len]; 
 
                //Populate the byte array with the contents of the FileStream object 
                fs.Read(ByteArray, 0, len); 
                   inDoc.MTOM = ByteArray;  
 
                //Retrieve credential information 
                   GetUsageRightsResult usageRightsResult = reClient.getDocumentUsageRights(inDoc); 
 
                //Get the message that is displayed in Adobe Reader when the 
                //rights-enabled document is opened 
                string message = usageRightsResult.message; 
 
                //Get usage rights to see if the enableFormFillIn is enabled     
                UsageRights myRight = usageRightsResult.rights; 
                bool ans = myRight.enabledFormFillIn ;  
 
                if (ans == true) 
                    Console.WriteLine("The enableFormFillIn usage right is enabled"); 
                else 
                    Console.WriteLine("The enableFormFillIn usage right is not enabled"); 
                } 
     
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
       } 
} 
 
 
 

// Ethnio survey code removed