本文中的範例和範例僅適用於AEM Forms的JEE環境。
使用Assembler Service API(web service)驗證DDX文檔:
包含專案檔案。
建立使用MTOM的Microsoft .NET專案。 請確定您使用下列WSDL定義:http://localhost:8080/soap/services/AssemblerService?WSDL&lc_version=9.0.1
。
將localhost替換為表單伺服器的IP地址。
建立PDF匯寫程式式用戶端。
使用其預設建構子建立AssemblerServiceClient
對象。
使用System.ServiceModel.EndpointAddress
建構函式建立AssemblerServiceClient.Endpoint.Address
物件。 將指定WSDL的字串值傳遞給AEM Forms服務(例如http://localhost:8080/soap/services/AssemblerService?blob=mtom
)。 您不需要使用lc_version
屬性。 建立服務參考時,將使用此屬性。
獲取AssemblerServiceClient.Endpoint.Binding
欄位的值,建立System.ServiceModel.BasicHttpBinding
對象。 將返回值轉換為BasicHttpBinding
。
將System.ServiceModel.BasicHttpBinding
物件的MessageEncoding
欄位設為WSMessageEncoding.Mtom
。 此值可確保使用MTOM。
執行下列工作以啟用基本HTTP驗證:
AssemblerServiceClient.ClientCredentials.UserName.UserName
。AssemblerServiceClient.ClientCredentials.UserName.Password
。HttpClientCredentialType.Basic
分配給欄位BasicHttpBindingSecurity.Transport.ClientCredentialType
。BasicHttpSecurityMode.TransportCredentialOnly
分配給欄位BasicHttpBindingSecurity.Security.Mode
。參考現有的DDX檔案。
BLOB
對象。 BLOB
物件用來儲存DDX檔案。System.IO.FileStream
對象的建構子並傳遞一個字串值,該字串值表示DDX文檔的檔案位置和開啟檔案的模式。System.IO.FileStream
對象內容的位元組陣列。 您可以取得System.IO.FileStream
物件的Length
屬性,以判斷位元組陣列的大小。System.IO.FileStream
物件的Read
方法,並傳遞要讀取的位元組陣列、開始位置和串流長度,以串流資料填入位元組陣列。MTOM
對象的屬性指定位元組陣列的內容來填充BLOB
對象。設定執行時期選項以驗證DDX檔案。
AssemblerOptionSpec
對象,該對象儲存運行時選項。AssemblerOptionSpec
物件的validateOnly
資料成員,以驗證DDX檔案。AssemblerOptionSpec
對象的logLevel
資料成員分配字串值,設定Assembler服務寫入日誌檔案的資訊量。 方法驗證DDX文檔時,需要將更多資訊寫入日誌檔案,以幫助驗證過程。 因此,您可以指定值FINE
或FINER
。 有關可設定的運行時選項的資訊,請參閱AEM FormsAPI參考中的AssemblerOptionSpec
類參考。執行驗證。
叫用AssemblerServiceClient
物件的invokeDDX
方法並傳遞下列值:
BLOB
對象。Map
對象的null
值。AssemblerOptionSpec
對象。invokeDDX
方法返回AssemblerResult
對象,該對象包含指定DDX文檔是否有效的資訊。
將驗證結果保存到日誌檔案中。
System.IO.FileStream
對象的建構子並傳遞一個字串值,該字串值表示日誌檔案的檔案位置和開啟檔案的模式。 請確定副檔名為。xml。AssemblerResult
對象的jobLog
資料成員的值,建立儲存日誌資訊的BLOB
對象。BLOB
對象內容的位元組陣列。 取得BLOB
物件的MTOM
欄位值,以填入位元組陣列。System.IO.BinaryWriter
對象的建構子並傳遞System.IO.FileStream
對象,以建立對象。System.IO.BinaryWriter
物件的Write
方法並傳遞位元組陣列,將位元組陣列的內容寫入PDF檔案。如果DDX文檔無效,則拋出OperationException
。 在catch語句中,可以獲取OperationException
對象jobLog
成員的值。
另請參閱