The following C# code example validates a DDX document
based on a file named bookmarkDDX.xml. (See Validating DDX Documents.)
???/**
* 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.
*
* The following quick start validates the following DDX document:
*&<?xml version="1.0" encoding="UTF-8"?>
* <DDX xmlns="http://ns.adobe.com/DDX/1.0/">
* <PDF result="out.pdf">
* <PDF source="map.pdf" />
* <PDF source="directions.pdf" />
* </PDF>
* </DDX>
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.IO;
using ValidateDDX.ServiceReference1;
namespace ValidateDDX
{
class Program
{
static void Main(string[] args)
{
try
{
//Create a AssemblerServiceClient object
AssemblerServiceClient assembleClient = new AssemblerServiceClient();
assembleClient.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://hiro-xp:8080/soap/services/AssemblerService?blob=mtom");
//Enable BASIC HTTP authentication
BasicHttpBinding b = (BasicHttpBinding)assembleClient.Endpoint.Binding;
b.MessageEncoding = WSMessageEncoding.Mtom;
assembleClient.ClientCredentials.UserName.UserName = "administrator";
assembleClient.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 object that represents the input DDX file
BLOB ddxDoc = new BLOB();
string ddxFileName = "C:\\bookmarkDDX.xml";
FileStream ddxFs = new FileStream(ddxFileName, FileMode.Open);
// Get the length of the file stream and create a byte array
int ddxLen = (int)ddxFs.Length;
byte[] ddxByteArray = new byte[ddxLen];
// Populate the byte array
ddxFs.Read(ddxByteArray, 0, ddxLen);
// Populate the BLOB object using its MTOM field
ddxDoc.MTOM = ddxByteArray;
// Create an AssemblerOptionsSpec object
AssemblerOptionSpec assemblerSpec = new AssemblerOptionSpec();
assemblerSpec.validateOnly = true;
assemblerSpec.logLevel = "FINE";
//Validate the DDX document
AssemblerResult result = assembleClient.invoke(ddxDoc, null, assemblerSpec);
//Save the log file
BLOB outDoc = result.jobLog;
//Populate a byte array with BLOB data
byte[] outByteArray = outDoc.MTOM;
//Write data to the logFile.xml file
string FILE_NAME = "C:\\logFile.xml";
FileStream fs2 = new FileStream(FILE_NAME, FileMode.OpenOrCreate);
BinaryWriter w = new BinaryWriter(fs2);
w.Write(outByteArray);
w.Close();
fs2.Close();
}
catch (Exception ee)
{
Console.WriteLine("An unexpected exception was encountered: " + ee.Message + "\n" + ee.StackTrace);
}
}
}
}
|
|
|