Show/Hide Toolbars

Therefore Web API Programming Interface 1.0

A Thereforeā„¢ document may contain one or more documents (e.g. 2 word documents, a PDF and 3 JPEG images), usually belonging to the same topic or task. These individual documents in a Thereforeā„¢ document are often referred to as streams. The Step-by-Step guide illustrates how to extract one or all of these streams from a document via the Web API.

 

To retrieve streams from the Therefore document you can use the GetDocument operation (with the parameter IsStreamsInfoAndDataNeeded set to true) or the GetDocumentStream operation if you need the data of one stream only.

 

 

 

 // 1. Create a channel factory to the web service endpoint

 ...

 ChannelFactory<IThereforeServicechannelFactory = new ChannelFactory<IThereforeService>(bindingendpoint);

 

 // 2. Create a channel to the web service endpoint

 IThereforeService service = channelFactory.CreateChannel();

 

 // 3. Create request parameters

 GetDocumentParams parameters = new GetDocumentParams();

 parameters.DocNo = = 123; // TODO: specify document number here

 parameters.IsStreamsInfoAndDataNeeded = true;

 

 // 4. Retrieve the document from the server

 GetDocumentResponse response = service.GetDocument(parameters);

 

 // 5. Close the channel and channel factory.

 ((IClientChannel)service).Close();

 channelFactory.Close();

 

 // 6. Extract all file streams to the specified directory

 string extractDir = "D:\\temp\\";

 string output = string.Empty;

 foreach (var streamInfo in response.StreamsInfo)

 {

         string extractFileName = Path.Combine(extractDirstreamInfo.FileName);

         File.WriteAllBytes(extractFileNamestreamInfo.StreamData);

         output += String.Format("Document stream extracted to {0}{1}"extractFileNameEnvironment.NewLine);

 }

 

 

 

Ā© 2022 Therefore Corporation, all rights reserved.