Quick Start (MTOM): Retrieving signature field names using the web service API

The following C# code example retrieves the names of signature fields located in a PDF document named LoanSig.pdf. (See Retrieving Signature Field Names.)

/** 
    * 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 RetrieveSignatureFieldName.ServiceReference1; 
 
namespace RetrieveSignatureFieldName 
{ 
       class Program 
       { 
           static void Main(string[] args) 
           { 
               try 
               { 
                   //Create a SignatureServiceClient object 
                   SignatureServiceClient sigClient = new SignatureServiceClient(); 
                   sigClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/SignatureService?blob=mtom"); 
 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)sigClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   sigClient.ClientCredentials.UserName.UserName = "administrator"; 
                   sigClient.ClientCredentials.UserName.Password = "password"; 
                   b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; 
                   b.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; 
                   b.MaxReceivedMessageSize = 2000000; 
                   b.MaxBufferSize = 2000000; 
                   b.ReaderQuotas.MaxArrayLength = 2000000; 
 
                   //Create a BLOB to store a PDF document 
                   BLOB inDoc = new BLOB(); 
 
                   //Specify a PDF document that contains signature fields 
                   string path = "C:\\Adobe\LoanSig.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 file stream 
                   fs.Read(byteArray, 0, len); 
 
                   //Populate the BLOB object 
                   inDoc.MTOM = byteArray; 
 
                   //Retrieve the name of the documents signature fields 
                   MyArrayOfPDFSignatureField fieldNames = sigClient.getSignatureFieldList(inDoc); 
 
                   //Obtain the name of each signature field  
                   string fieldName = ""; 
                   for (int i = 0; i < fieldNames.Count; i++) 
                   { 
                       PDFSignatureField pdfSignatureField = (PDFSignatureField)fieldNames[i]; 
                       fieldName = pdfSignatureField.name; 
                       Console.WriteLine("The name of the signature field is" + fieldName); 
                   } 
               } 
 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
       } 
} 
 

// Ethnio survey code removed