Retrieve Documents |
Scroll |
Retrieval is the process of reading documents and their index data information from the server. Given a document's unique number, the Step-by-Step guide shows how to retrieve a document from the Web API service.
You can retrieve index data, file streams (including binary data of streams), and the checkout status of the document. Please see parameter details in the GetDocument section.
1 |
Create a channel factory to the web service endpoint. |
2 |
Create a channel to the web service endpoint. |
3 |
Create requested parameter instances. Set the requested document number and other parameters. |
4 |
Execute the GetDocument operation to get document data from the server. |
5 |
Close the channel and channel factory. |
6 |
Process response. |
// 1. Create a channel factory to the web service endpoint
...
ChannelFactory<IThereforeService> channelFactory = new ChannelFactory<IThereforeService>(binding, endpoint);
// 2. Create a channel for the web service endpoint
IThereforeService service = channelFactory.CreateChannel();
// 3. Create requested parameters
GetDocumentParams parameters = new GetDocumentParams();
parameters.DocNo = docNo;
parameters.IsStreamsInfoNeeded = true;
parameters.IsIndexDataValuesNeeded = 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. Process response.
string docInfo = String.Format("Successfully retrieved {0}Document No: {1}", Environment.NewLine, response.DocNo);
foreach (var streamInfo in response.StreamsInfo)
docInfo += String.Format("{0}Stream No: {1}, File name: {2}", Environment.NewLine, streamInfo.StreamNo, streamInfo.FileName);
foreach (var indexDataItem in response.IndexData.IndexDataItems)
docInfo += String.Format("{0}Index data field no: {1}, value: {2}", Environment.NewLine, indexDataItem.Value.FieldNo, indexDataItem.Value.ObjDataValue);
MessageBox.Show(docInfo);