【发布时间】:2011-05-20 17:21:52
【问题描述】:
我正在创建一个网络服务客户端。我遇到了问题 - 在 MainWindow.xaml 中有一条消息:在 ServiceModel 客户端配置部分中找不到名为“LightsWSSoap”和合同“LightsWS.LightsWSSoap”的端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。 在这个文件中,我有类似的内容:
xmlns:vm="clr-namespace:LightsClient2.ViewModels"
<Window.DataContext>
<vm:MainWindowViewModel />
</Window.DataContext>
并且在MainWindowViewModel中使用了webservice的构造函数:
LightsWSSoap lService = new LightsWSSoapClient("LightsWSSoap");
“LightsWS”是服务的名称。
有一个app.config文件,里面有enpoints定义:
<client>
<endpoint address="http://xxx/Lights/LightsWS.asmx"
binding="basicHttpBinding" bindingConfiguration="LightsWSSoap"
contract="LightsWS.LightsWSSoap" name="LightsWSSoap" />
<endpoint address="http://xxx/Lights/LightsWS.asmx"
binding="customBinding" bindingConfiguration="LightsWSSoap12"
contract="LightsWS.LightsWSSoap" name="LightsWSSoap12" />
</client>
怎么了?有什么想法吗?
【问题讨论】:
-
是
LightsWS.LightsWSSoap- 接口吗? (应该是)如果是,那为什么不以 I 开头(LightsWS.ILightsWSSoap)。您打算使用哪种类型的端点? basicHttpBinding 还是 customBinding? -
这是一个接口,是VS自动生成的;目前是基本的
-
你的问题解决了吗?