beb*_*lei 17 c# soap webservice-client
我有一个SOAP Web服务,可在多个服务器上使用,因此具有多个端点.我想避免添加具有不同名称的多个服务引用(C#SOAP端口客户端),以便与此服务进行通信,因为API完全相同.
有没有办法在运行时配置端点URI?
Jim*_*mbo 24
我使用以下功能很好:
ServiceReference1.wsSoapClient ws= new ServiceReference1.wsSoapClient();
ws.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://xxx/myservice.asmx");
Run Code Online (Sandbox Code Playgroud)
我也很难找到这个.我终于借用了配置绑定并做了这个:
private static wsXXXX.IwsXXXXClient wsXXXXClientByServer(string sServer)
{
// strangely, these two are equivalent
WSHttpBinding binding = new WSHttpBinding("WSHttpBinding_IwsXXXX");
// WSHttpBinding binding = new WSHttpBinding(SecurityMode.Message, false);
EndpointAddress remoteAddress = new EndpointAddress(new Uri(string.Format("http://{0}:8732/wsXXXX/", sServer)), new UpnEndpointIdentity("PagingService@rl.gov"));
return new wsXXXX.IwsXXXXClient(binding, remoteAddress);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
42550 次 |
| 最近记录: |