Reputation: 9
I am working on a task where I have to list the number of applications calling our web/wcf services.
Currently I am looking into the applications folders structure, and looking for the folder "Web References" to list all web services.
But this way of finding the total list for WCF services does not work because WCF services can be consumed in many other ways.
Is there a foolproof way of doing this?
Upvotes: 1
Views: 100
Reputation: 5391
You can add custom headers to client configuration.
<endpoint address="http://localhost:8080"
binding="basicHttpBinding"
contract="CalService.ICalService">
<headers>
<ClientIdentification>Cal1</ClientIdentification>
</headers>
</endpoint>
And retrive that using following code
var operationContext = OperationContext.Current;
var requestContext = operationContext .RequestContext;
var headers = requestContext.RequestMessage.Headers;
int headerIndex = headers.FindHeader("ClientIdentification", "");
var clientHeaderString = headers.GetHeader<string>(headerIndex);
see this also.
Upvotes: 0
Reputation: 4173
One of ways would be implementing your own message inspector on server, deriving from IDispatchMessageInspector, and logging IP address of every request (see example here).
If you need more detailed information, for example, if there are multiple clients on one machine - you need to include client identification into your contract, and send it either in custom headers, or implement authentication. But of course, this does not prevent multiple clients from using same identity.
Upvotes: 1