WCF 找不到终结点元素和协定



我正在尝试创建一个 WCF 并从另一个 C# 类使用它。

我认为我做的一切都是正确的,但我收到错误消息说合同名称不熟悉。

这是我的 Web.config 代码:

<system.serviceModel>
    <services>
      <service behaviorConfiguration="PNMSoft.Sequence.Invoices.InvoicesBehavior" name="PNMSoft.Sequence.Invoices.Invoices">
        <endpoint name="InvoicesEndPoint" address="" binding="wsHttpBinding" contract="PNMSoft.Sequence.Invoices.IInvoices">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="PNMSoft.Sequence.Invoices.InvoicesBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
</system.serviceModel>

这是我的接口代码:

namespace PNMSoft.Sequence.Invoices
{
    [ServiceContract]
    public interface IInvoices
    {
        [OperationContract]
        void SendInvoicesToCustomer(int wfid, int userID, int type, string mail, DateTime startDate, DateTime endDate, string clientCode);
    }
}

这是我尝试从服务激活函数时的代码:

InvoicesClient client = new InvoicesClient("InvoicesEndPoint");
client.SendInvoicesToCustomer(IWFID, userID2, type2, Mail, DateFrom2, DateTo2, clientCode2);

在第一行,我收到此错误消息:"在 ServiceModel 客户端配置部分中找不到名称为'InvoicesEndPoint'和合同'Invoices.IInvoices'的终结点元素。这可能是因为找不到应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。

这是我这边的配置文件:

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="InvoicesEndPoint" />
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="InvoicesEndPoint" contract="Invoices.IInvoices" name="InvoicesEndPoint">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我想我需要在客户端的配置文件中添加一些东西。我应该添加什么?

提前谢谢你!

我解决了它,我只需要将端点添加到客户端的配置中。

相关内容

  • 没有找到相关文章

最新更新