WCF 找不到终结点元素和协定
WCF Could not find endpoint element and contract
我正在尝试创建一个 WCF 并从另一个 C# 使用它 class。
我认为我做的一切都是正确的,但我收到错误消息说合同名称不熟悉。
这是我的 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);
在第一行我收到此错误消息:"Could not find endpoint element with name 'InvoicesEndPoint' and contract 'Invoices.IInvoices' 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 name could be found in the client element."。
这是我父母这边的配置文件:
<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>
我想我需要在客户端的配置文件中添加一些内容。我应该添加什么?
提前致谢!
我解决了,我只需要将端点添加到客户端的配置中即可。
我正在尝试创建一个 WCF 并从另一个 C# 使用它 class。
我认为我做的一切都是正确的,但我收到错误消息说合同名称不熟悉。
这是我的 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);
在第一行我收到此错误消息:"Could not find endpoint element with name 'InvoicesEndPoint' and contract 'Invoices.IInvoices' 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 name could be found in the client element."。
这是我父母这边的配置文件:
<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>
我想我需要在客户端的配置文件中添加一些内容。我应该添加什么?
提前致谢!
我解决了,我只需要将端点添加到客户端的配置中即可。