Quick Start (MTOM): Modifying a policy using the web service API

The following web service C# code example modifies a policy named Allow Copy. When modifying a policy’s offline lease period using a web service, the offlineLeasePeriod field on the PolicySpec interface is ignored. To update the offline lease period, modify the OfflineLeasePeriod element in the PDRL XML document. Then reference the updated PDRL XML document by using the PolicySpec interface’s policyXML data member. (See Modifying Policies.)

???/** 
    * 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 ModifyPolicy.ServiceReference1; 
 
namespace ModifyPolicy 
{ 
       class Program 
       { 
           static void Main(string[] args) 
           { 
               try 
               { 
                   //Create a RightsManagementServiceClient object 
                   RightsManagementServiceClient rmClient = new RightsManagementServiceClient(); 
                   rmClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/RightsManagementService?blob=mtom"); 
 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)rmClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   rmClient.ClientCredentials.UserName.UserName = "administrator"; 
                   rmClient.ClientCredentials.UserName.Password = "password"; 
                   b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
                   b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 
 
                   //Retrieve an existing policy named AllowCopy 
                   PolicySpec policy = rmClient.getPolicy( 
                       "Global Policy Set", 
                       "Allow Copy"); 
 
                   //Modify the policy???s description attributes 
                   policy.description = "This is a test policy"; 
     
                   //Update the policy 
                   rmClient.updatePolicyFromSDK(policy); 
 
               } 
 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
       } 
}