コード例 #1
0
        /// <summary>
        /// Creates a new instance, specifying the URL, credentials, and version used
        /// for the SharePoint site.
        /// </summary>
        /// <param name="webUrl">The URL for the SharePoint site.</param>
        /// <param name="credential">The credentials to use when invoking service operations.</param>
        /// <param name="version">The version of the Nintex Forms service endpoint.</param>
        /// <remarks>If this constructor is invoked, a binding and form digest are generated
        /// and used for requests to the service endpoint.</remarks>
        public NfClientContext(string webUrl, NetworkCredential credential, Version version)
        {
            // Validate parameters
            if (String.IsNullOrEmpty(webUrl))
            {
                throw new ArgumentNullException("webUrl",
                                                "The webUrl parameter cannot be set to a null value or empty string.");
            }
            if (credential == null)
            {
                throw new ArgumentNullException("credential",
                                                "The credential parameter cannot be set to a null value.");
            }

            // Create instance
            _proxy = new FormsWcfServiceProxy(GetDefaultBinding(), new EndpointAddress(webUrl));
            var clientCredentials = _proxy.ClientCredentials;

            if (clientCredentials != null)
            {
                clientCredentials.Windows.ClientCredential          = credential;
                clientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Identification;
            }
            _proxy.Endpoint.Behaviors.Add(new FormsHeaderBehavior(FormDigestFactory.Current.Get(version, webUrl, credential).FormDigestValue));
            WebUrl      = webUrl;
            Credentials = credential;
        }
コード例 #2
0
        /// <summary>
        /// Creates a new instance, specifying the URL, binding, and form digest used for
        /// the Nintex Forms service endpoint.
        /// </summary>
        /// <param name="webUrl">The URL for the SharePoint site.</param>
        /// <param name="binding">The binding to use.</param>
        /// <param name="formDigestValue">The form digest value to use.</param>
        /// <remarks>If this constructor is invoked, the specified binding and form digest
        /// are used for requests to the service endpoint. The credential property is not set.</remarks>
        public NfClientContext(string webUrl, Binding binding, string formDigestValue)
        {
            // Validate parameters
            if (String.IsNullOrEmpty(webUrl))
            {
                throw new ArgumentNullException("webUrl",
                                                "The webUrl parameter cannot be set to a null value or empty string.");
            }
            if (binding == null)
            {
                throw new ArgumentNullException("binding",
                                                "The binding parameter cannot be set to a null value.");
            }
            if (String.IsNullOrEmpty(formDigestValue))
            {
                throw new ArgumentNullException("formDigestValue",
                                                "The formDigestValue parameter cannot be set to a null value or empty string.");
            }

            // Create instance
            _proxy = new FormsWcfServiceProxy(binding, new EndpointAddress(webUrl));
            _proxy.Endpoint.Behaviors.Add(new FormsHeaderBehavior(formDigestValue));
            WebUrl = webUrl;
        }