我正在研究封装在 COM-dll 中的 SOAP 客户端。不幸的是,我无法提供 app.config,因此我必须在运行时插入我的值:
try
{
var dataSet = ConfigurationManager.GetSection("system.data") as System.Data.DataSet;
dataSet.Tables[0].Rows.Add("FirebirdClient Data Provider"
, ".Net Framework Data Provider for Firebird"
, "FirebirdSql.Data.FirebirdClient"
, "FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c");
}
catch
{ }
但我不知道如何在运行时设置默认代理:
<system.net>
<defaultProxy useDefaultCredentials="true"/>
</system.net>
如果没有此选项,我将无法通过代理进行通信...
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress(Adress);
ServiceReference.DataTransferationServiceSoap serviceClient = new ServiceReference.DataTransferationServiceSoapClient(basicHttpBinding, endpointAddress);
serviceClient.doSomething();
如何在运行时设置 useDefaultCredentials?