How can I add a header/datamember to all DataContracts in a WCF service? -


I want to add existing services and add authorization for every call. The problem I have is that I do not know how to do it best, what I need to do is send the name of the module calling the WCF service. I am already sending the username and password for the service and now I need to expand it with the name of the module calling that service. This is because we can allow a user to open a module and open the data with another module, but not one-third.

If we use message contracts, I will add only one MessageHeader for this and set the header when I made the request. Unfortunately, with the data contracts, there is not an option, I am thinking.

Adding a datamember to the base class with order = 1000 or something like that, I do not know what will happen if we add another datamember before, though?

Build assets for module names and instead set headers to transport. Although this one is not really fond of

Edit1: The problem is not whether it is the least bad or you have a better suggestion? How to send a header for the service, the problem is how to send the header to the server with a specific value. In the Message Inspector, I can make general examples only with the message. GetBody & lt; DataContract & gt; (); It means I have to know the type that I do not know how to

Edit 2: This issue is that in our application we want to restrict access to calls based on the call from where the call is made, Have to pass. Suppose I call MyService from FindUserModule, then I need to add that module to the top so that the Authorization Manager can check that the user must be actually authorized. This is due to the service call used with many modules.

Take it as a SOAP header.

Comments