Skip to content

Commit

Permalink
Enable Data Contract Serialization for Remoting Exceptions (#629)
Browse files Browse the repository at this point in the history
* Enable Data Contract Serialization for Remoting Exceptions

* Make updates to the correct files

* Add setting during initialization

* Proposed change to not break secure remoting

* Using TryLoadForm to get default settings

* bug fix, add missing semicolon

* Update src/Hosting.Services.Remoting/RemotingListenerBuilder.cs

* Update src/Services.Remoting/Client/OmexServiceProxyFactory.cs

---------

Co-authored-by: Keith Cully <[email protected]>
  • Loading branch information
Pr1ynka and K-Cully authored Nov 9, 2023
1 parent 7c17193 commit 27610b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Hosting.Services.Remoting/RemotingListenerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ protected RemotingListenerBuilder(
string name,
FabricTransportRemotingListenerSettings? settings = null)
{
if (settings == null)
{
if (!FabricTransportRemotingListenerSettings.TryLoadFrom("TransportSettings", out settings))
{
settings = new FabricTransportRemotingListenerSettings();
}
}

settings.ExceptionSerializationTechnique = FabricTransportRemotingListenerSettings.ExceptionSerialization.Default;
Name = name;
Settings = settings;
}
Expand Down
16 changes: 14 additions & 2 deletions src/Services.Remoting/Client/OmexServiceProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.ServiceFabric.Services.Remoting.Client;
using Microsoft.ServiceFabric.Services.Remoting.FabricTransport;
using Microsoft.ServiceFabric.Services.Remoting.FabricTransport.Runtime;
using Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Client;

namespace Microsoft.Omex.Extensions.Services.Remoting.Client
Expand All @@ -20,16 +21,27 @@ namespace Microsoft.Omex.Extensions.Services.Remoting.Client
public static class OmexServiceProxyFactory
{
private static ServiceProxyFactory s_serviceProxyFactory = new(handler =>
new OmexServiceRemotingClientFactory(
{
FabricTransportRemotingSettings remotingSettings;
if (!FabricTransportRemotingSettings.TryLoadFrom("TransportSettings", out remotingSettings))
{
remotingSettings = new FabricTransportRemotingSettings();
}
remotingSettings.ExceptionDeserializationTechnique = FabricTransportRemotingSettings.ExceptionDeserialization.Default;
return new OmexServiceRemotingClientFactory(
new FabricTransportServiceRemotingClientFactory(
remotingCallbackMessageHandler: handler)));
remotingCallbackMessageHandler: handler,
remotingSettings: remotingSettings));
});

/// <summary>
/// Binds custom transport settings to the service proxy factory.
/// If non-default secure remoting configuration is required, call this before calling OmexServiceProxyFactory.Instance.
/// </summary>
public static void WithCustomTransportSettings(FabricTransportRemotingSettings transportSettings)
{
transportSettings.ExceptionDeserializationTechnique = FabricTransportRemotingSettings.ExceptionDeserialization.Default;
s_serviceProxyFactory = new ServiceProxyFactory(handler =>
new OmexServiceRemotingClientFactory(
new FabricTransportServiceRemotingClientFactory(
Expand Down

0 comments on commit 27610b5

Please sign in to comment.