Connect to DocuWare |
In order to connect to DocuWare you can use the ServiceConnection class. Pass either a user name and password or a token to the Create method.
The DocuWare Platform supports also NTLM authentication. If you prefer this authentication method you can use CreateWithWindowsAuthentication method.
If you have only one organization in your system, you do no need to specify it. In case there are more than a single organization in your system, the organization name must be specified. The organization is specified with an optional parameter.
In case you want to enable client-side caching you must provide a WebRequestHandler instance.
using System; using System.Collections.Generic; using System.Linq; using System.Net.Cache; using System.Net.Http; using DocuWare.Platform.ServerClient; namespace DocuWare.PlatformClientExamples { static partial class Examples { static Uri uri = new Uri("https://my.docuware-service.com/docuware/platform"); static public ServiceConnection Connect() { return ServiceConnection.Create(uri, "admin", "admin"); } static public ServiceConnection ConnectWithUserAgent() { return ServiceConnection.Create(uri, "admin", "admin", userAgent: new System.Net.Http.Headers.ProductInfoHeaderValue[] { new System.Net.Http.Headers.ProductInfoHeaderValue("DocuWare+.NET+API+Test+Client", "1.0") }); } static public ServiceConnection ConnectWithOrg() { return ServiceConnection.Create(uri, "admin", "admin", organization: "Peters Engineering"); } static public ServiceConnection ConnectWithCaching() { var handler = new WebRequestHandler() { CachePolicy = new RequestCachePolicy(RequestCacheLevel.Default) }; return ServiceConnection.Create(uri, "admin", "admin", httpClientHandler: handler); } static public ServiceConnection ConnectWithNTLM() { return ServiceConnection.CreateWithWindowsAuthentication(uri, "Administrator", "admin"); } static public ServiceConnection ConnectWithDefaultUser() { return ServiceConnection.CreateWithWindowsAuthentication(uri, System.Net.CredentialCache.DefaultCredentials); } } }
using System; using System.Collections.Generic; using System.Linq; using System.Net.Cache; using System.Net.Http; using System.Threading.Tasks; using DocuWare.Platform.ServerClient; namespace DocuWare.PlatformClientExamples { static partial class ExamplesAsync { static Uri uri = new Uri("http://cw01/docuware/platform"); static async public Task<ServiceConnection> ConnectAsync() { return await ServiceConnection.CreateAsync(uri, "admin", "admin"); } static async public Task<ServiceConnection> ConnectWithOrgAsync() { return await ServiceConnection.CreateAsync(uri, "admin", "admin", organization: "Peters Engineering"); } static async public Task<ServiceConnection> ConnectWithCachingAsync() { var handler = new WebRequestHandler() { CachePolicy = new RequestCachePolicy(RequestCacheLevel.Default) }; return await ServiceConnection.CreateAsync(uri, "admin", "admin", httpClientHandler: handler); } static async public Task<ServiceConnection> ConnectWithNTLMAsync() { return await ServiceConnection.CreateWithWindowsAuthenticationAsync(uri, "Administrator", "admin"); } static async public Task<ServiceConnection> ConnectWithDefaultUserAsync() { return await ServiceConnection.CreateWithWindowsAuthenticationAsync(uri, System.Net.CredentialCache.DefaultCredentials); } } }