public void CanGetAccountsPayable()
        {
            // Arrange
            const string vendorId = "Contoso";
            var          binding  = new BasicHttpBinding();

            binding.Security = new BasicHttpSecurity()
            {
                Mode      = BasicHttpSecurityMode.TransportCredentialOnly,
                Transport = new HttpTransportSecurity()
                {
                    ClientCredentialType = HttpClientCredentialType.Windows
                }
            };
            EndpointAddress addr = new EndpointAddress("http://localhost:81/Vendor/Service.svc");
            ChannelFactory <IVendorServices> factory = new ChannelFactory <IVendorServices>(binding, addr);
            IVendorServices proxy = factory.CreateChannel();

            // Act
            double accountsPayable = proxy.GetAccountsPayable(vendorId);

            // Assert
            Assert.IsTrue(accountsPayable >= 0.0);

            factory.Close();
        }
        public override object Execute(SPProxyOperationArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            try
            {
                AccountsPayableProxyArgs proxyArgs = args as AccountsPayableProxyArgs;

                string vendorName      = proxyArgs.VendorName;
                double accountsPayable = 0.0;

                BasicHttpBinding binding = new BasicHttpBinding();
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                EndpointAddress endpointAddress = new EndpointAddress(address);
                using (ChannelFactory <IVendorServices> factory = new ChannelFactory <IVendorServices>(binding, endpointAddress))
                {
                    IVendorServices proxy = factory.CreateChannel();
                    accountsPayable = proxy.GetAccountsPayable(vendorName);
                    factory.Close();
                }

                return(accountsPayable);
            }
            catch (Exception excpt)
            {
                return(excpt);
            }
        }
 public VendorController(IVendorServices iVendorServices)
 {
     _IVendorServices = iVendorServices;
 }
Esempio n. 4
0
 public VendorsController(VendorServices crewServices)
 {
     this.crewServices = crewServices;
 }