Пример #1
0
        private ServiceJSONClient ConfigureClientProxy()
        {
            BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);

            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;

            // Replace <machinename> with the name of the development server.
            EndpointAddress remoteAddress = new EndpointAddress(string.Format("{0}/soap", wcfAddress.Text));

            ServiceJSONClient client = new ServiceJSONClient(binding, remoteAddress);

            using (HostingEnvironment.Impersonate())
            {
                client.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;
            }

            return(client);
        }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ServiceJSONClient MyClient = ConfigureClientProxy();

            MyClient.Open();
            MyClient.MyMethodCompleted += new EventHandler <MyMethodCompletedEventArgs>(MyMethodCompleted);


            ServiceJSONInput InputData = new ServiceJSONInput {
                Customer = new Customer {
                    FirstName = "Steve",
                    LastName  = "Jobs"
                },
                Account = new Account {
                    UserName = "******",
                    Password = "******"
                }
            };

            MyClient.MyMethodAsync(InputData);
        }