Ok, I found the answer myself. Hope this helps someone;).
This part creates a binding. It can be later used in webservice.
private void button2_Click(object sender, EventArgs e) { BasicHttpBinding binding = new BasicHttpBinding("TempConvertSoap"); if (!string.IsNullOrEmpty(tbProxy.Text)) { binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic; string proxy = string.Format("http://{0}", tbProxy.Text); if (!string.IsNullOrEmpty(tbPort.Text)) { proxy = string.Format("{0}:{1}",proxy,tbPort.Text); } binding.UseDefaultWebProxy = false; binding.ProxyAddress = new Uri(proxy); } EndpointAddress endpoint = new EndpointAddress(@"http://www.w3schools.com/webservices/tempconvert.asmx");
This is where the old part begins, where I set the binding.
try { //Create Client ServiceReference1.TempConvertSoapClient client = new ServiceReference1.TempConvertSoapClient(binding, endpoint); if (client.ClientCredentials != null) { //Use Values which are typed in in the GUI string user = tbUser.Text; string password = tbPassword.Text; string domain = tbDomain.Text; client.ClientCredentials.UserName.UserName = user; client.ClientCredentials.UserName.Password = password; client.ClientCredentials.Windows.ClientCredential.Domain = domain; //Check what information is used by the customer. if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(domain)) { client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(user, password, domain); } if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(password)) { client.ClientCredentials.Windows.ClientCredential = new NetworkCredential(user, password); } } //Oh nooo... no temperature typed in if (string.IsNullOrEmpty(tbFahrenheit.Text)) { //GOOD BYE return; } //Use the webservice //THIS ONE IS IMPORTANT System.Net.ServicePointManager.Expect100Continue = false; string celsius = client.FahrenheitToCelsius(tbFahrenheit.Text); //<-- Simple Calculation tbCelsius.Text = celsius; } catch(Exception ex) { //Something tbCelsius.Text = ex.Message; MessageBox.Show(ex.ToString()); } }
I used Squid as a proxy server and used a firewall in addition to the proxy server. After I configured it successfully, I encountered an error (417). Waiting failed. During the research, I found a line of code that helped me "solve" this problem.
System.Net.ServicePointManager.Expect100Continue = false;
Bongo source share