简体   繁体   中英

How can I find out the list of applications using a particular hosted web/wcf service?

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM