Quick Start (MTOM): Creating Associations using the web service API (Deprecated)

The following C# code creates an association between an XML data file and a PDF form. This type of association is named LinkedBy. The PDF document must have the aspect linkable applied to it. (See Creating Content Services (deprecated) Associations.)

???/** 
    * 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 CreateAssociations.ServiceReference1; 
using System.IO; 
 
namespace CreateAssociations 
{ 
       class Program 
       { 
           static void Main(string[] args) 
           { 
               try 
               { 
                   //Specify the input values  
                   String storeName = "SpacesStore"; 
                   String associationType = "{http://www.adobe.com/lc/datacapture/1.0}linkedBy"; 
                   String aspect = "{http://www.adobe.com/lc/datacapture/1.0}linkable"; 
                   String parentPath = "/Company Home/MortgageForm.pdf"; 
                   String childPath = "/Company Home/Loan.xml"; 
 
                   //Create a DocumentManagementServiceClient object 
                   DocumentManagementServiceClient docManagement = new DocumentManagementServiceClient(); 
                   docManagement.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/DocumentManagementService"); 
 
                   BasicHttpBinding b = (BasicHttpBinding)docManagement.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
 
                   //Enable BASIC HTTP authentication 
                   docManagement.ClientCredentials.UserName.UserName = "administrator"; 
                   docManagement.ClientCredentials.UserName.Password = "password"; 
                   b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
                   b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 
 
                   //Set the linkable aspect to MortgageForm.pdf 
                   CreateAssociations.ServiceReference1.MyArrayOf_xsd_string aspectList = new CreateAssociations.ServiceReference1.MyArrayOf_xsd_string(); 
                   aspectList.Add(aspect); 
 
                   //Set content attributes 
                   CreateAssociations.ServiceReference1.MyMapOf_xsd_string_To_xsd_anyType inputs = new MyMapOf_xsd_string_To_xsd_anyType(); 
 
                   //Set the Description attribute 
                   CreateAssociations.ServiceReference1.MyMapOf_xsd_string_To_xsd_anyType_Item desAttribute = new MyMapOf_xsd_string_To_xsd_anyType_Item(); 
                   desAttribute.key = "{http://www.alfresco.org/model/content/1.0}description"; 
                   desAttribute.value = "A mortgage application form"; 
 
                   //Set the creator attribute 
                   CreateAssociations.ServiceReference1.MyMapOf_xsd_string_To_xsd_anyType_Item creator = new MyMapOf_xsd_string_To_xsd_anyType_Item(); 
                   creator.key = "{http://www.alfresco.org/model/content/1.0}creator"; 
                   creator.value = "Tony Blue"; 
 
                   //Set the items to the MyMapOf_xsd_string_To_xsd_anyType instance 
                   inputs.Add(desAttribute); 
                   inputs.Add(creator); 
 
                   //Set the aspects 
                   docManagement.setContentAttributesAPI(storeName, parentPath, aspectList, inputs); 
 
                   //Create an association between MortgageForm.pdf and Loan.xml  
                   docManagement.createAssociation(storeName, 
                           associationType, 
                           parentPath, 
                           childPath);  
     
               } 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
 
           } 
       } 
}