On my local machine in Visual Studio 2017, I created solution based on the .NET Core Stateless Service template, and added Microsoft.ServiceFabric.Services.Remoting.Runtime package to accept remote calls through RPC.
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return this.CreateServiceRemotingInstanceListeners();
}
Then I added interface ITestAccUp in a separate project:
public interface ITestAccUp : IService
{
Task NotifyAsync();
}
I added implementation of the interface to the stateless service, and created one more project, a .NET Core console client to run the service. The console is going to be run outside a cluster.
static void Main(string[] args)
{
ITestAccUp testAccUpClient = ServiceProxy.Create<ITestAccUp>(new Uri("fabric:/SFAccountUpTest/Stateless1"));
testAccUpClient.NotifyAsync().Wait();
}
However, when I run it I got the error "InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricTestManagementClient4'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B96AA7D4-ACC0-4814-89DC-561B0CBB6028}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).", though Named Application fabric:/SFAccountUpTest/Stateless1 seems to be up and running.
I guess the problem is RPC calls are just made for calling services inside SF clusters, not outside. Is it possible to make an RPC call outside a cluster, or is it necessary to build some sort of web API to make a service call?