過去幾周我一直從Cloud Services遷移到Service Fabric,並且使用2個服務之間的Remoting運行了幾個絆腳石。服務結構服務遠程處理
我一直在使用的服務Remoting的官方文檔和示例代碼,特別是我試圖讓這裏列出的工作樣本:
我有2個服務。一個名爲「RemoteService」,另一個名爲「CallerService」。兩者都來自默認的無狀態服務項目。
在這兩個「RemoteService」,我還增加了以下接口來形容他們之間的服務合同「CallerService」項目:
public interface IMyService : IService
{
Task<string> HelloNameAsync(string name);
}
在「RemoteService」我已經在RemoteService類中創建相關方法
public Task<string> HelloNameAsync(string name)
{
return Task.FromResult("Hello " + name + "!");
}
我也覆蓋CreateServiceInstanceListeners具有以下
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[] { new ServiceInstanceListener(context => this.CreateServiceRemotingListener(context)) };
}
在我「CallerService」當我嘗試用下面的連接撥打電話到 「RemoteService」:
IMyService helloNameClient = ServiceProxy.Create<IMyService>(new Uri("fabric:/Application/RemoteService"));
string message = await helloNameClient.HelloNameAsync("Luke");
我得到這個例外
InnerException = {"Interface id '1994370306' is not implemented by object 'RemoteService.RemoteService'"}
我已經過了這個樣本,用細齒梳,我確信我擁有了我所有的東西應該是這樣。我已經閱讀了關於設置端點並將服務註冊到服務目錄的信息,但是從我瞭解的那些服務目錄來看,這些是針對外部服務的,Remoting文檔沒有提及這一點。
UPDATE:
這裏是RemoteService類是如何聲明:
internal sealed class RemoteService : StatelessService, IMyService
更新2
這裏是什麼將Settings.xml看起來像這兩種服務。這些是項目開箱即可使用的默認設置。我沒有添加或刪除任何東西。我還想指出,我在本地服務結構上運行所有這些。
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<!-- Add your custom configuration sections and parameters here -->
<!--
<Section Name="MyConfigSection">
<Parameter Name="MyParameter" Value="Value1" />
</Section>
-->
</Settings>
我們能否看到您如何聲明RemoteService類?還爲這兩個服務Settings.xml。 – cassandrad
是的,我剛添加了一個更新。 – CodeAbundance
剛剛添加了Settings.xml文件。 – CodeAbundance