/// <summary>
        ///
        /// </summary>
        /// <param name="accountCredentials"></param>
        /// <returns>A disposable object you should wrap in using() statement</returns>
        public static DocuSignWeb.APIServiceSoap CreateApiProxy(AccountCredentials accountCredentials)
        {
#if true
            // the envelope is finally constructed we are ready to send it in
            DocuSignWeb.APIServiceSoapClient apiService = new DocuSignWeb.APIServiceSoapClient("APIServiceSoap", accountCredentials.ApiUrl);

            apiService.ClientCredentials.UserName.UserName = accountCredentials.UserName;
            apiService.ClientCredentials.UserName.Password = accountCredentials.Password;

            return(apiService);
#else       // this is a security token configuration
            // this is required for certain calls like RequestRecipientToken
            // you need to get a certificate from Thawte or VeriSign first and install it
            DocuSignWeb.APIServiceSoapClient apiService = new DocuSignWeb.APIServiceSoapClient("APIServiceSoap1", accountCredentials.ApiUrl);
            apiService.ClientCredentials.UserName.UserName = "******" + ConfigurationManager.AppSettings["IntegratorsKey"] + "]" + ConfigurationManager.AppSettings["APIUserEmail"];
            apiService.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["Password"];

            //
            // need to add the supporting token since DocuSign uses dual authentication for
            // for critical calls
            CustomBinding                   binding         = (CustomBinding)apiService.Endpoint.Binding;
            BindingElementCollection        elements        = binding.CreateBindingElements();
            SecurityBindingElement          security        = elements.Find <SecurityBindingElement>();
            UserNameSecurityTokenParameters tokenParameters = new UserNameSecurityTokenParameters();
            tokenParameters.InclusionMode      = SecurityTokenInclusionMode.AlwaysToRecipient;
            tokenParameters.RequireDerivedKeys = false;
            security.EndpointSupportingTokenParameters.SignedEncrypted.Add(
                tokenParameters);
            apiService.Endpoint.Binding = new CustomBinding(elements.ToArray());;
            return(apiService);
#endif
        }
        public static System.ServiceModel.Channels.Binding BuildCustomBindingSecure(MessageEncodingType encodingType, MessageSecurityType securityType,
                                                                                    BindingSecurity transportSecurity, TimeoutQuotas timeoutQuotas, MessageSizeQuotas sizeQuotas)
        {
            if (sizeQuotas == null)
            {
                sizeQuotas = new MessageSizeQuotas()
                {
                    MaxBufferPoolSize      = 15000000,
                    MaxReceivedMessageSize = 15000000,
                    MaxBufferSize          = 15000000
                };
            }

            if (timeoutQuotas == null)
            {
                timeoutQuotas = new TimeoutQuotas()
                {
                    CloseTimeout   = 600000000,  // 1 minute
                    OpenTimeout    = 600000000,  // 1 minute
                    ReceiveTimeout = 3000000000, // 5 minutes
                    SendTimeout    = 3000000000, // 5 minutes
                };
            }
            SecurityBindingElement messageSecurity = BuildMessageSecurity(securityType);

            MessageEncodingBindingElement messageEncodingBindingElement = BuildMessageEncoding(encodingType, sizeQuotas);

            HttpTransportBindingElement transportBindingElement = BuildHttpTransport(transportSecurity, sizeQuotas);

            if (securityType == MessageSecurityType.MutualCertificate || securityType == MessageSecurityType.CertificateOverTransport)
            {
                ((HttpsTransportBindingElement)transportBindingElement).RequireClientCertificate = true;
            }

            BindingElementCollection bindingElementCollection = new BindingElementCollection();

            if (messageSecurity != null)
            {
                bindingElementCollection.Add(messageSecurity);
            }
            bindingElementCollection.Add(messageEncodingBindingElement);
            bindingElementCollection.Add(transportBindingElement);

            CustomBinding cb = new CustomBinding(bindingElementCollection);

            cb.ReceiveTimeout = new TimeSpan(timeoutQuotas.ReceiveTimeout);
            cb.CloseTimeout   = new TimeSpan(timeoutQuotas.CloseTimeout);
            cb.OpenTimeout    = new TimeSpan(timeoutQuotas.OpenTimeout);
            cb.SendTimeout    = new TimeSpan(timeoutQuotas.SendTimeout);
            cb.CreateBindingElements();
            return(cb);
        }
Exemple #3
0
        public void CtorFromAnotherBinding()
        {
            CustomBinding cb =
                new CustomBinding(new WSHttpBinding());

            // Its properties become mostly copy of the original one
            Assert.AreEqual(4, cb.Elements.Count, "#1");
            Assert.AreEqual("http", cb.Scheme, "#2");
            Assert.AreEqual("WSHttpBinding", cb.Name, "#3");
            Assert.AreEqual("http://tempuri.org/", cb.Namespace, "#4");

            Assert.AreEqual(4, cb.CreateBindingElements().Count, "#9");
        }
Exemple #4
0
        public void DefaultCtor()
        {
            CustomBinding cb = new CustomBinding();

            Assert.AreEqual(0, cb.Elements.Count, "#1");
            Assert.AreEqual("CustomBinding", cb.Name, "#3");
            Assert.AreEqual("http://tempuri.org/", cb.Namespace, "#4");
            Assert.AreEqual(TimeSpan.FromMinutes(1), cb.OpenTimeout, "#5");
            Assert.AreEqual(TimeSpan.FromMinutes(1), cb.CloseTimeout, "#6");
            Assert.AreEqual(TimeSpan.FromMinutes(1), cb.SendTimeout, "#7");
            Assert.AreEqual(TimeSpan.FromMinutes(10), cb.ReceiveTimeout, "#8");
            Assert.AreEqual(0, cb.CreateBindingElements().Count, "#9");
        }
        public static System.ServiceModel.Channels.Binding BuildHttpBinding()
        {
            MtomMessageEncodingBindingElement mtomEncodingBindingElement =
                new MtomMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, System.Text.Encoding.UTF8);

            HttpTransportBindingElement transportBindingElement = new HttpTransportBindingElement();


            BindingElementCollection bindingElementCollection = new BindingElementCollection();

            bindingElementCollection.Add(mtomEncodingBindingElement);
            bindingElementCollection.Add(transportBindingElement);

            CustomBinding cb = new CustomBinding(bindingElementCollection);

            cb.CreateBindingElements();
            return(cb);
        }
        public static APIServiceSoap CreateApiProxy(Account Identity, string password)
        {
#if true
            // the envelope is finally constructed we are ready to send it in
            AccountCredentials accountCredentials = new AccountCredentials();

            //If there are many accounts then the firet one is chosen for sending
            accountCredentials.AccountId = Identity.AccountID;
            accountCredentials.ApiUrl    = "https://demo.docusign.net/api/3.0/api.asmx";
            APIServiceSoapClient apiService = new APIServiceSoapClient("APIServiceSoap", accountCredentials.ApiUrl);
            apiService.ClientCredentials.UserName.UserName = Identity.UserID;
            apiService.ClientCredentials.UserName.Password = password;

            return(apiService);
#else       // this is a security token configuration
            // this is required for certain calls like RequestRecipientToken
            // you need to get a certificate from Thawte or VeriSign first and install it
            DocuSignWeb.APIServiceSoapClient apiService = new DocuSignWeb.APIServiceSoapClient("APIServiceSoap1", accountCredentials.ApiUrl);
            apiService.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["APIUserName"];
            apiService.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["Password"];

            //
            // need to add the supporting token since DocuSign uses dual authentication for
            // for critical calls
            CustomBinding                   binding         = (CustomBinding)apiService.Endpoint.Binding;
            BindingElementCollection        elements        = binding.CreateBindingElements();
            SecurityBindingElement          security        = elements.Find <SecurityBindingElement>();
            UserNameSecurityTokenParameters tokenParameters = new UserNameSecurityTokenParameters();
            tokenParameters.InclusionMode      = SecurityTokenInclusionMode.AlwaysToRecipient;
            tokenParameters.RequireDerivedKeys = false;
            security.EndpointSupportingTokenParameters.SignedEncrypted.Add(
                tokenParameters);
            apiService.Endpoint.Binding = new CustomBinding(elements.ToArray());;
            return(apiService);
#endif
        }