c# - Identifying WCF Client ID -


I have a WCF web service that exposes many business methods I have two clients - ASPNT GUI and a data migration Apps that connect to both WCF backend and connect to different business transactions.

I need to be able to identify and identify my backend, in which the WCF client has called some variant logic.

Is there any way that my WCF service is able to identify customers associated with it? There is also a way to use a signed key to prevent a customer from cheating on their identity?

You resolve it with a custom header.

You can add a custom header as part of the endpoint in the client application's configuration file. You will then make each customer's custom headings different. For example, in the ASP.NET version:

  & endpoint name = "basicHttpEndpoint" address = "http: // localhost: 8972" binding = "basicHttpBinding" contract = "MySeriveContractLib.IMyService" & Gt; & Lt; Header & gt; & Lt; ClientIdentification & gt; ASP_Client & lt; / ClientIdentification & gt; & Lt; / Headers & gt; & Lt; / Endpoint & gt;  

Then check the service header value such as:

  Public Zero MyServiceMethod () {var opcontext = OperationContext.Current; Var requestContext = opContext.RequestContext; Var header = requestContext.RequestMessage.Headers; Int headerIndex = headers.FindHeader ("client identification", ""); Var client string = header. GetHeader & lt; String & gt; (Header-endx); If clientString == "ASP_Client" {// ...} Other {// ...}}  

Comments