Quick Start (MTOM): Passing documents to the Forms Service using the web service API

The following C# quick start retrieves the file Loan.xdp from Content Services (deprecated). This XDP file is located in the space /Company Home/Form Designs. The XDP file is returned in a com.adobe.idp.Document instance. The com.adobe.idp.Document instance is passed to the Forms service. The interactive form is saved as a PDF file named Loan.pdf. (See Passing Documents to the Forms Service.)

???/** 
    * 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; 
 
//A reference to the Forms service  
using PassDocument.ServiceReference1; 
 
//A reference to the Document Management service  
using PassDocument.ServiceReference2; 
 
namespace PassDocument 
{ 
       class Program 
       { 
           static void Main(string[] args) 
           { 
               try 
               { 
                   //Because BLOB objects are used in both service references 
                   //it is necessary to fully-qualify the BLOB objects 
 
                   //Retrieve the XDP file from Content Services (deprecated) 
                   PassDocument.ServiceReference2.BLOB xdpContent = GetFormDesign(); 
 
                   //Create a BLOB object associated with the Forms service 
                   PassDocument.ServiceReference1.BLOB formDesign = new PassDocument.ServiceReference1.BLOB(); 
 
                   //Transfer the byte stream from one BLOB object to the  
                   //Forms BLOB object 
                   formDesign.MTOM = xdpContent.MTOM; 
 
                   //Render the interactive form 
                   RenderInteractiveForm(formDesign); 
               } 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
 
           //Get the form design from Content Services (deprecated) - invoke the Document  
           //Management service 
           private static PassDocument.ServiceReference2.BLOB GetFormDesign() 
           { 
 
               try 
               { 
                   //Specify the name of the store and node 
                   String storeName = "SpacesStore"; 
                   String nodeName = "/Company Home/Form Designs/Loan.xdp"; 
 
                   //Create a DocumentManagementServiceClient object 
                   DocumentManagementServiceClient docManagement = new DocumentManagementServiceClient(); 
                   docManagement.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/DocumentManagementService?blob=mtom"); 
 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)docManagement.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   docManagement.ClientCredentials.UserName.UserName = "administrator"; 
                   docManagement.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; 
 
                   //Prepare output values 
                   CRCResult content; 
                   String outVal; 
                   PassDocument.ServiceReference2.BLOB outDoc; 
                   PassDocument.ServiceReference2.MyMapOf_xsd_string_To_xsd_anyType nodeAttributes; 
 
                   //Retrieve /Company Home/Form Designs/Loan.xdp 
                   docManagement.retrieveContent(storeName, 
                       nodeName, 
                       "", 
                       out outVal, 
                       out outDoc, 
                       out nodeAttributes, 
                       out content); 
 
                 return outDoc; 
               } 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
 
               return null; 
           } 
 
           //Render the Form -- invoke the Forms service 
           private static void RenderInteractiveForm(PassDocument.ServiceReference1.BLOB pdfForm) 
           { 
 
               try 
               { 
                   //Create a FormsServiceClient object 
                   FormsServiceClient formsClient = new FormsServiceClient(); 
                   formsClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/FormsService?blob=mtom"); 
 
                   //Enable BASIC HTTP authentication 
                   BasicHttpBinding b = (BasicHttpBinding)formsClient.Endpoint.Binding; 
                   b.MessageEncoding = WSMessageEncoding.Mtom; 
                   formsClient.ClientCredentials.UserName.UserName = "administrator"; 
                   formsClient.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; 
 
                   PDFFormRenderSpec renderSpec = new PDFFormRenderSpec(); 
                   renderSpec.generateServerAppearance = true; 
 
                   //Set out parameter values 
                   long pageCount = 1; 
                   String localeValue = "en_US"; 
                   FormsResult result = new FormsResult(); 
 
                   //Render an interactive PDF form by ivoking the renderPDFForm2 method 
                   formsClient.renderPDFForm2( 
                       pdfForm, 
                       null, 
                       renderSpec, 
                       null, 
                       null, 
                       out pageCount, 
                       out localeValue, 
                       out result); 
     
                   //Populate a byte array with BLOB data that represents the signed form 
                   PassDocument.ServiceReference1.BLOB outDoc = result.outputContent; 
                   byte[] outByteArray = outDoc.MTOM; 
 
                   //Save the signed PDF document 
                   string fileName = "C:\\Adobe\Loan.pdf"; 
                   FileStream fs2 = new FileStream(fileName, FileMode.OpenOrCreate); 
 
                   //Create a BinaryWriter object 
                   BinaryWriter w = new BinaryWriter(fs2); 
                   w.Write(outByteArray); 
                   w.Close(); 
                   fs2.Close(); 
               } 
 
               catch (Exception ee) 
               { 
                   Console.WriteLine(ee.Message); 
               } 
           } 
       } 
} 
 

// Ethnio survey code removed