Retrieving registry information in a WCF service

I am working on a service that will support mobile applications on the Android, BlackBerry, iOS and WP7 platforms. These applications will connect to the various REST-based WCF services I'm working on. I would like to know what information the client application passes to my service. To do this, I wrote the current operation in my WCF service:

[OperationContract]
[WebGet(UriTemplate = "/GetRequesterInfo")]
public string GetRequesterInfo()
{
  OperationContext context = OperationContext.Current;

  string message = "Session ID: " + context.SessionId;
  return message;
}

When I call this code, I notice that it SessionIdis an empty string. In addition, I would like to get as much information as possible about the client. For example, if it was ASP.NET, I could use the object HttpRequestand get:

  • HTTPMethod
  • Islocal
  • IsSecureConnection
  • RequestType
  • Url.AbsoluteUri
  • Url.OriginalString
  • Useragent
  • UserHostAddress
  • UserHostName
  • Browser.id
  • Browser.Browser
  • Browser.CanInitiateVoiceCall
  • Browser.ClrVersion.Minor
  • Browser.Cookies
  • Browser.EcmaScriptVersion
  • Browser.GatewayVersion
  • Browser.InputType
  • Browser.MobileDeviceManufacturer
  • Browser.MobileDeviceModel

, , . :

  • , , WCF? , OperationContext. .
  • / , WCF?
  • -, , ? , .
+3
1

System.ServiceModel.Channels.MessageProperties:

OperationContext context = OperationContext.Current;

if (context != null)
{
    MessageProperties messageProperties = context.IncomingMessageProperties;

, HttpRequest, .

MessageProperties, , :

alt text

+4

Source: https://habr.com/ru/post/1783638/


All Articles