过去几周我一直从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