我需要能夠爲我創建的Web服務中的每個接口配置一個端點。 使用測試Web窗體應用程序,我可以成功使用任一接口。但是,當我嘗試添加第二個端點與第二接口,我得到的錯誤如下:爲具有多個接口的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>
這是網絡。從測試應用程序配置文件:
<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>
這是Web服務接口的代碼:
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? – HOKBONG
這是在Web服務文件中。爲了避免公開元數據信息,請將下面的值設置爲false,並在部署前刪除上面的元數據端點 - >> < <! - 爲了調試而接收故障中的異常詳細信息,請將下面的值設置爲true。在部署之前設置爲false以避免公開異常信息 - > serviceBehaviors> –