I am trying to use a ServiceReference in a C# project. The project is intended to test a connection. I have a customer who is trying to connect with a C# application to one web service of one of my colleagues. The connection can't be established and he is assuming that it is our own mistake.
I am trying to write now a simple C# project. Thats enough of story... now the Information needed.
- The customer uses a Proxy server
- I try to connect to this web service for testing reasons http://www.w3schools.com/webservices/tempconvert.asmx
- I Use .Net Framework 4.0
- My Project compiles into a Windows Forms application.
Here The source code of my Method:
private void button2_Click(object sender, EventArgs e)
{
try
{
//Create Client
ServiceReference1.TempConvertSoapClient client = new ServiceReference1.TempConvertSoapClient(@"TempConvertSoap",@"http://www.w3schools.com/webservices/tempconvert.asmx");
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;
//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
string celsius = client.FahrenheitToCelsius(tbFahrenheit.Text); //<-- Simple Calculation
tbCelsius.Text = celsius;
}
catch(Exception ex)
{
//Something
MessageBox.Show(ex.ToString());
}
}
Here is my Question: How can i set a proxy to this service reference or rather the client ? There is no property or setter for this purpose. I tried it with the ClientCredentials