在C#中跳过App.config配置和配置

时间:2015-09-23 20:51:31

标签: c# web-services wcf soap config

如果我想从我的客户端代码中删除app.config配置的必要性,并从我的c#初始化客户端。在我的C#代码中定义Bindings和EndPoint。什么是以下客户端代码的c#版本:

<client>
            <endpoint address="http://employeetstsvc/Employee.svc" binding="wsHttpBinding"
                bindingConfiguration="StandardEndpoint" contract="ServiceReference2.IHREmployee"
                name="StandardEndpoint" />
        </client>

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

如下所示。查看更多Here

String baseAddress = "http://employeetstsvc/Employee.svc";

WSHttpBinding binding1 = new WSHttpBinding();

using(ServiceHost host = new ServiceHost(typeof(Employee)))
{
   host.AddServiceEndpoint(typeof(ServiceReference2.IHREmployee),binding1, baseAddress);
}