我無法找出WCF服務出現問題,此服務在我爲其擴展功能實施「v2」合同後出現。一切都很好,但當我嘗試訪問瀏覽器中的服務時,我只會被告知它無法連接。當我嘗試將其添加爲服務參考時,我會收到有關連接問題的類似消息。但是,當我從配置文件中刪除擴展合同的端點,並保持原來的「v1」版本不變時,它可以正常工作。版本控制服務合約後無法訪問WCF服務
這裏是 「V1」 合同:
namespace Company.Services.Ticketing.Retail.Contracts
{
[ServiceContract(Name = "OutletReportingContract_v1", Namespace = "https://enterprise.company.ie/Services/Retail")]
public interface IOutletReportingContract_v1
{
/* methods */
}
}
這裏是 「V2」 的合同:
namespace Company.Services.Ticketing.Retail.Contracts
{
[ServiceContract(Name = "OutletReportingContract_v2", Namespace = "https://enterprise.company.ie/Services/Retail")]
public interface IOutletReportingContract_v2 : IOutletReportingContract_v1
{
/* methods */
}
}
下面是在Web.config端點:
<service name="Company.Services.Ticketing.Retail.OutletService" behaviorConfiguration="Public">
<endpoint address="1" binding="wsHttpBinding" bindingConfiguration="Standard" name="OutletReportingContract_v1"
contract="Company.Services.Ticketing.Retail.Contracts.IOutletReportingContract_v1" />
<endpoint address="2" binding="wsHttpBinding" bindingConfiguration="Standard" name="OutletReportingContract_v2"
contract="Company.Services.Ticketing.Retail.Contracts.IOutletReportingContract_v2" />
<endpoint address="mex" binding="mexHttpsBinding" name="IMetadataExchange" contract="IMetadataExchange" />
</service>
這裏是出現在事件查看器中的錯誤消息:
WebHost無法處理請求。 發件人信息:System.ServiceModel.Activation.HostedHttpRequestAsyncResult/28075619 異常:System.Web.HttpException(0x80004005):沒有在'https://phil-pc.company.local/Services/Retail/OutletService.svc/_vti_bin/ListData.svc/ $ metadata'上有效監聽的頻道。這通常是由不正確的地址URI造成的。確保消息發送到的地址與服務正在偵聽的地址匹配。 ---> System.ServiceModel.EndpointNotFoundException:沒有頻道在'https://phil-pc.company.local/Services/Retail/OutletService.svc/_vti_bin/ListData.svc/ $ metadata'上積極監聽。這通常是由不正確的地址URI造成的。確保消息發送到的地址與服務正在偵聽的地址匹配。 在System.ServiceModel.Activation.HostedHttpTransportManager.HttpContextReceived(HostedHttpRequestAsyncResult結果) 在System.ServiceModel.Activation.HostedHttpRequestAsyncResult.HandleRequest() 在System.ServiceModel.Activation.HostedHttpRequestAsyncResult.BeginRequest() 在System.Runtime.AsyncResult.End [TAsyncResult](IAsyncResult的結果) 在System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult的結果) 進程名稱:W3WP 進程ID:8148
現在有點難倒並希望任何幫助:)
嘿,感謝您的回覆! 我其實忘了添加v2合約從v1合約繼承的事實,我已更新我的帖子以反映這一點。 關於您的解決方案,問題在於我在帖子中使用的格式對另一項服務工作正常,並且在實施中沒有明顯差異。 – achillesminor