如何从使用 C#.net 创建的 ActiveX 控件调用动态 Web 服务?

How to call dynamic web service from ActiveX Control created using C#.net?

我有一个调用网络的 activex 控件 service.This 网络服务可以在任何地方托管,因此不知道它 url。 但是我们可以从我们使用了activex控件的网页中将web服务url发送到activex控件中。 我想在 activex 控件中动态设置 url 以便它将替换在创建安装程序期间使用的控件。

我已经在 activex 控件的用户控件中尝试了以下代码

ServiceReference1.abcServiceSoapClient c = new ServiceReference1.abcServiceSoapClient("abcServiceSoap");
c.Endpoint.Address = new System.ServiceModel.EndpointAddress("WebServiceURL");

但给出以下异常

Could not find default endpoint element that references contract 'ServiceReference1.abcServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

如果是 WinForm 或 WebForm,通过将 class 库的 'app.config' 的内容附加到 winform 中的 'App.config' 和 webform 中的 'Web.config' 来处理此异常。

但不知道在 activex 控件库的情况下该怎么做,因为它嵌入在 Web 表单中。

那么,请问如何在activex控件中设置一个动态的web服务URL,让控件调用网页发送的web服务?

提前致谢。

通过使用 Web Reference 而不是 Service Reference.[=11= 解决了 ]

下面显示的代码片段

 WebReference1.abcWebService client = new WebReference1.abcWebService();
 client.Url = WebServiceURL;