0

I am using a service fabric Rest API and i need to add some custom headers to my requests.

I am using both a stateless implementation of the service fabric.

When receiving information in the HttpMessageRequest I have the headers there containing information.

I initiate my stateless service using the following code:

// in api controller:
proxy = Proxy.ForMicroservice<IServiceInterface>();


// in the Proxy class:
public static I Create<I>(Uri serviceAddress, UserData data) where I : class, IService
{
    var returnval = ServiceProxy.Create<I>(serviceAddress,listenerName:Naming.Listener<I>());
    return returnval;
}

I tried the following article (from stack overflow) but it seems to be oriented on WCF. I also expected there to be a more out of the box information about this.

How can i maintain my header information which I received in the original call, or at least transfer this information to my stateless service, without using something like an wrapper Data transfer object?

Community
  • 1
  • 1
martijn
  • 1,417
  • 1
  • 16
  • 26
  • It's not WCF specific, try using the `FabricTransportServiceRemotingClientFactory` as inner. – LoekD Mar 17 '17 at 14:40

2 Answers2

0

You can use CallContext to set the headers . After wards,follow this sample on how to send customHeaders to service .

https://github.com/Azure-Samples/service-fabric-dotnet-getting-started/tree/master/Services/ServiceRemotingCustomHeaders/ServiceRemotingCustomHeaders

0

It looks like you want to do something like this Passing user and auditing information in calls to Reliable Services in Service Fabric transport. You need to set and pass your custome header information in the fabric transport call end then pick that up on the recieving (service side). CallContext can be used to convey that header information from the MethodDispather to any internal service logic without having to rely on expanding your service methods to include it as arguments.

Community
  • 1
  • 1
yoape
  • 3,285
  • 1
  • 14
  • 27