Quick Start (MTOM): Creating a watermark using the web service API

The following C# code example creates a new watermark named Confidential. The custom text attribute is set to display Confidential. (See Creating Watermarks.)

???/** 
    * 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 CreateWatermark.ServiceReference1; 
 
namespace CreateWatermark 
{ 
       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; 
 
                   //Set the watermark properties 
                   CreateWatermark.ServiceReference1.MyArrayOf_xsd_anyType myCollectionObject = new CreateWatermark.ServiceReference1.MyArrayOf_xsd_anyType(); 
 
                   //Define the key/value pairs required by the Rights Management service 
                   MyMapOf_xsd_string_To_xsd_anyType_Item valueMapSpec = new MyMapOf_xsd_string_To_xsd_anyType_Item(); 
                   valueMapSpec.key = "WaterBackCmd:IS_USERID_ENABLED"; 
                   valueMapSpec.value = "true"; 
     
                   //Set the text enabled property 
                   MyMapOf_xsd_string_To_xsd_anyType_Item valueMapSpec1 = new MyMapOf_xsd_string_To_xsd_anyType_Item(); 
                   valueMapSpec1.key = "WaterBackCmd:IS_CUSTOMTEXT_ENABLED"; 
                   valueMapSpec1.value = "True"; 
 
                   //Set the opacity property 
                   MyMapOf_xsd_string_To_xsd_anyType_Item valueMapSpec2 = new MyMapOf_xsd_string_To_xsd_anyType_Item(); 
                   valueMapSpec2.key = "WaterBackCmd:OPACITY"; 
                   valueMapSpec2.value = ".25"; 
 
                   //Set the text property 
                   MyMapOf_xsd_string_To_xsd_anyType_Item valueMapSpec3 = new MyMapOf_xsd_string_To_xsd_anyType_Item(); 
                   valueMapSpec3.key = "WaterBackCmd:SRCTEXT"; 
                   valueMapSpec3.value = "Confidential"; 
 
                   //Add each MyMapOf_xsd_string_To_xsd_anyType_Item instance to the 
                   //the MyMapOf_xsd_string_To_xsd_anyType object 
                   myCollectionObject.Add(valueMapSpec); 
                   myCollectionObject.Add(valueMapSpec1); 
                   myCollectionObject.Add(valueMapSpec2); 
                   myCollectionObject.Add(valueMapSpec3); 
 
                   //Create a WatermarkSpec object and set its watermarks attributes 
                   WatermarkSpec watermark = new WatermarkSpec(); 
                   watermark.name = "Confidential"; 
                   watermark.id = "Confidential"; 
                   watermark.values = myCollectionObject; 
 
                   //Register the watermark 
                   rmClient.registerWatermark(watermark); 
               } 
 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
       } 
}