BasicHttpBinding myBinding new BasicHttpBinding myBinding Security Mod

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
BasicHttpBinding myBinding = new BasicHttpBinding();
myBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
EndpointAddress ea = new EndpointAddress(textBoxWS.Text.Trim());
IntegrationPortTypeClient Service = new IntegrationPortTypeClient(myBinding, ea);
Service.ClientCredentials.UserName.UserName = textBoxLogin.Text.Trim();
Service.ClientCredentials.UserName.Password = textBoxPassword.Text.Trim();
Contragent res = Service.GetList();
if (res.ElementsContragents != null)
{
foreach (Contragent cn in res.ElementsContragents)
{
int inxRow = dataGridViewContragents.Rows.Add();
dataGridViewContragents.Rows[inxRow].Cells["rowCode"].Value = cn.Code.ToString();
dataGridViewContragents.Rows[inxRow].Cells["rowName"].Value = cn.Name.ToString();
dataGridViewContragents.Rows[inxRow].Cells["rowINN"].Value = cn.INN.ToString();
dataGridViewContragents.Rows[inxRow].Cells["rowKPP"].Value = cn.KPP.ToString();
}
}