Validate a DDX document using the web service API validate-a-ddx-document-using-theweb-service-api
Samples and examples in this document are only for AEM Forms on JEE environment.
Validate a DDX document by using the Assembler Service API (web service):
-
Include project files.
Create a Microsoft .NET project that uses MTOM. Ensure that you use the following WSDL definition:
http://localhost:8080/soap/services/AssemblerService?WSDL&lc_version=9.0.1
.note note NOTE Replace localhost with the IP address of the Forms Server. -
Create a PDF Assembler client.
-
Create an
AssemblerServiceClient
object by using its default constructor. -
Create an
AssemblerServiceClient.Endpoint.Address
object by using theSystem.ServiceModel.EndpointAddress
constructor. Pass a string value that specifies the WSDL to the AEM Forms service (for example,http://localhost:8080/soap/services/AssemblerService?blob=mtom
). You do not need to use thelc_version
attribute. This attribute is used when you create a service reference. -
Create a
System.ServiceModel.BasicHttpBinding
object by getting the value of theAssemblerServiceClient.Endpoint.Binding
field. Cast the return value toBasicHttpBinding
. -
Set the
System.ServiceModel.BasicHttpBinding
object’sMessageEncoding
field toWSMessageEncoding.Mtom
. This value ensures that MTOM is used. -
Enable basic HTTP authentication by performing the following tasks:
- Assign the AEM forms user name to the field
AssemblerServiceClient.ClientCredentials.UserName.UserName
. - Assign the corresponding password value to the field
AssemblerServiceClient.ClientCredentials.UserName.Password
. - Assign the constant value
HttpClientCredentialType.Basic
to the fieldBasicHttpBindingSecurity.Transport.ClientCredentialType
. - Assign the constant value
BasicHttpSecurityMode.TransportCredentialOnly
to the fieldBasicHttpBindingSecurity.Security.Mode
.
- Assign the AEM forms user name to the field
-
-
Reference an existing DDX document.
- Create a
BLOB
object by using its constructor. TheBLOB
object is used to store the DDX document. - Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the DDX document and the mode to open the file in. - Create a byte array that stores the content of the
System.IO.FileStream
object. You can determine the size of the byte array by getting theSystem.IO.FileStream
object’sLength
property. - Populate the byte array with stream data by invoking the
System.IO.FileStream
object’sRead
method and passing the byte array, the starting position, and the stream length to read. - Populate the
BLOB
object by assigning itsMTOM
property with the contents of the byte array.
- Create a
-
Set run-time options to validate the DDX document.
- Create an
AssemblerOptionSpec
object that stores run-time options by using its constructor. - Set the run-time option that instructs the Assembler service to validate the DDX document by assigning the value true to the
AssemblerOptionSpec
object’svalidateOnly
data member. - Set the amount of information that the Assembler service writes to the log file by assigning a string value to the
AssemblerOptionSpec
object’slogLevel
data member. method When validating a DDX document, you want more information written to the log file that will assist in the validation process. As a result, you can specify the valueFINE
orFINER
. For information about the run-time options that you can set, see theAssemblerOptionSpec
class reference in AEM Forms API Reference.
- Create an
-
Perform the validation.
Invoke the
AssemblerServiceClient
object’sinvokeDDX
method and pass the following values:- A
BLOB
object that represents the DDX document. - The value
null
for theMap
object that usually stores PDF documents. - An
AssemblerOptionSpec
object that specifies run-time options.
The
invokeDDX
method returns anAssemblerResult
object that contains information that specifies whether the DDX document is valid. - A
-
Save the validation results in a log file.
- Create a
System.IO.FileStream
object by invoking its constructor and passing a string value that represents the file location of the log file and the mode to open the file in. Ensure that the file name extension is .xml. - Create a
BLOB
object that stores log information by getting the value of theAssemblerResult
object’sjobLog
data member. - Create a byte array that stores the content of the
BLOB
object. Populate the byte array by getting the value of theBLOB
object’sMTOM
field. - Create a
System.IO.BinaryWriter
object by invoking its constructor and passing theSystem.IO.FileStream
object. - Write the contents of the byte array to a PDF file by invoking the
System.IO.BinaryWriter
object’sWrite
method and passing the byte array.
note note NOTE If the DDX document is invalid, an OperationException
is thrown. Within the catch statement, you can get the value of theOperationException
object’sjobLog
member. - Create a
See also