简体   繁体   中英

Cannot consume WCF service in desktop application

I created a WCF service that has a one way (void) method.

When I create a new Windows Forms application, I can add the service reference and call the method with no problems.

When I add the reference to the actual project we need it on, the reference doesn't even appear and the error cannot find namespace shows.

So while adding the service reference, in advanced I removed the reuse types check box and then the service is there but when I call the code I get an error on the line that initializes the service:

var smsService = new SMSWebMethod.ServiceClient();

Error:

Could not find default endpoint element that references contract 'SMSWebMethod.IService' 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.

Here is the <system.serviceModel> section of the app.config file

<system.serviceModel>
  <bindings>
   <basicHttpBinding>
    <binding name="BasicHttpBinding_IService" />
   </basicHttpBinding>
  </bindings>
  <client>
   <endpoint address="url/Service.svc" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IService" contract="SMSWebMethod.IService"
    name="BasicHttpBinding_IService" />
  </client>
 </system.serviceModel>

好的,似乎有一个覆盖app.config的配置文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM