简体   繁体   中英

Could not find default endpoint element … in WCF Client

I created a proxy Library Class in the Service Solution referencing the Contract Assembly as well and copied the libraries (Contract,Proxy) to another solution folder. Then referenced the Proxy,Contract and System.ServiceModel libraries in another class library where i need to use the one method contained, as well as adding an App.Config inside the library.

The Service is hosted in a windows forms application. The client is a class library called from a windows forms application.I haven't created an App.Config inside the windows form project. In fact the Windows Form project loads a control in a library and the control loads the library where i need to use the service method. So i thought i should only reference the (Contract and proxy) in the latest assembly since i wont use it anywhere else.

But i keep getting this error:

Could not find default endpoint element that references contract 'Sign.Contracts.ISignDocument' 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.

App.Config in libray calling the proxy:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <client>
        <endpoint
          address="http://localhost:8731/SignHere"
          binding="basicHttpBinding"
          contract="Sign.Contracts.ISignDocument" />
      </client>
    </services>
  </system.serviceModel>
</configuration>

App.Config in service Host:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="Sign.Service.SignDocumentService">
        <endpoint 
          address="http://localhost:8731/SignHere" 
          binding="basicHttpBinding" 
          contract="Sign.Contracts.ISignDocument" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

the Proxy class:

namespace Sign.Proxies
{
    public class Proxy : ClientBase<ISignDocument>, ISignDocument
    {
        public string SignDocument(string document)
        {
            return Channel.SignDocument(document);
        }
    }
}

the Contract class:

namespace Sign.Contracts
{
    [ServiceContract]
    public interface ISignDocument
    {
        [OperationContract]
        string SignDocument(string document);
    }
}

Any ideas?

Any program has only a single configuration file. In your case, that's the app.config of the Winforms program, which gets copied to programName.exe.config when the program is built.

Any WCF configuration has to be in that file. The fact that your library has an app.config doesn't matter. You need to copy the relevant configuration entries from the library's app.config, and merge them with the app.config of the Winforms application.

oo ...客户端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