【发布时间】:2014-02-18 21:32:57
【问题描述】:
我需要能够为我创建的 Web 服务中的每个接口配置一个端点。 使用测试网络表单应用程序,我可以成功使用任一界面。但是当我尝试使用第二个接口添加第二个端点时,我收到以下错误:
以下是 Web 服务的 web.config 文件:
<basicHttpBinding>
<binding name="myBindingConfiguration1" closeTimeout="00:01:00" />
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="PaymentServiceBehavior" name="PaymentService.PaymentService">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBindingConfiguration1"
name="PaymentInsecureService" contract="PaymentService.IPaymentService" />
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBindingConfiguration1"
name="PaymentSecureService" contract="PaymentService.IPaymentSecureService" />
</service>
</services>
这是来自测试应用程序的 web.config 文件:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPaymentService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:4567/Payment.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IPaymentService" contract="PaymentService.IPaymentService"
name="PaymentInsecureService" />
<endpoint address="http://localhost:4567/Payment.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IPaymentService" contract="PaymentService.IPaymentSecureService"
name="PaymentSecureService" />
</client>
这是网络服务接口的代码:
namespace PaymentService
{
[ServiceContract (Namespace = "name of namespace here")]
public interface IPaymentSecureService
{
//Initiate a credit card authorization.
[OperationContract(IsOneWay = true)]
void Authorize(...12 parameters here...);
more methods here....
}
}
namespace PaymentService
{
[ServiceContract (Namespace = "name of namespace here")]
public interface IPaymentService
{
//Initiate a credit card authorization.
[OperationContract(IsOneWay = true)]
void Authorize(...13 parameters here....);
more methods here...
}
}
当其中一个接口方法名称相同但方法签名不同时,是否可以为每个接口设置一个端点?
我的配置文件有问题吗?
谢谢。
【问题讨论】:
-
您是否尝试过在元端点上启用 httpGet?
-
这是在 Web 服务文件中。
标签: c# web-services interface web-config