Health​Service​Request Class

Definition

Represents an individual request to a HealthVault service. The class wraps up the XML generation and web request/response.

public class HealthServiceRequest
Inheritance
HealthServiceRequest

Remarks

An instance of this class can be retrieved by calling the CreateRequest(String, Int32) method. This class is not thread safe. A new instance should be created when multiple requests must execute concurrently.

Constructors

Health​Service​Request(​Health​Service​Connection, ​String, ​Int32)

Creates a new instance of the HealthServiceRequest class for the specified method.

Health​Service​Request(​Health​Service​Connection, ​String, ​Int32, ​Health​Record​Accessor)

Creates a new instance of the HealthServiceRequest class for the specified method.

Properties

Culture​Code

Gets or sets the culture-code for the request.

Impersonated​Person​Id

Gets or sets the identifier of the person being impersonated.

Method​Name

Gets or sets the method name to call.

Method​Version

Gets or sets the version of the method to call.

Parameters

Gets or sets the parameters for the method invocation. The parameters are specified via XML for the particular method.

Record​Id

Gets or sets the record identifier.

Request​Compression​Method

Gets or sets the request compression method used by the connection.

Response

Gets the response after Execute is called.

Response​Stream​Handler

Defines a delegate that gets or sets all responses for requests to the HealthVault Service.

Timeout​Seconds

Gets or sets the timeout for the request, in seconds.

Methods

Build​Request​Xml()

Connects the XML using default values.

Build​Request​Xml(​String)

Connects the XML using the specified optional XSL.

Cancel​Request()

Cancels any pending request to HealthVault that was initiated with the same connection as this request.

Execute()

Builds up the XML, makes the request and reads the response. Connectivity failures will except out of the http client

Execute​For​Transform(​String)

Same as Execute, but takes a transform url (or tag) that is used to transform the result (on the server). Since the response is no longer necessarily xml, it is returned as a string

Get​Correlation​Id()

Gets the correlation id that was set by the user. For web applications, the correlation id was set inside of HttpContext.Current.Items, so GetCorrelationId will retrieve from the HttpContext

        For non web applications, it will return whatever was set in the [ThreadStatic] variable.
Get​Last​Response​Id()

Gets the last response id that was returned by the HealthVault platform. The response id is found in the response headers and is set when a request finishes executing.

        For web applications, the response id is stored in the HttpContext items to be shared across
        the web request.

        For non web applications, the response id is stored in thread local storage so the last response
        in the current thread will be returned.

        If an error occurs / exception thrown, the caller can call GetLastResponseId to get that response
        id which can be used to look up error information in the HealthVault logs.
Handle​Response(​Stream, ​Web​Header​Collection)

Represents the Microsoft.Health.IEasyWebResponseHandler callback.

Handle​Response​Result(​Stream, ​Web​Header​Collection)

Handles the response data and headers retrieved from the web request.

Handle​Response​Stream(​Stream)

Represents the Microsoft.Health.IEasyWebResponseHandler callback.

Handle​Response​Stream​Result(​Stream)

Handles the data retrieved by making the web request.

Set​Correlation​Id(​Guid)

To allow applications to keep track of calls to platform, the application can optionally set a correlation id. This will be passed up in web requests to HealthVault and used when HealthVault writes to its logs. If issues occur, this id can be used by the HealthVault team to help debug the issue.

        For asp.net applications, we want to avoid the use of thread local for setting
        the request id since a single web request is not guaranteed to fully execute on the
        same thread - using HttpContext.Items is the recommended way.

        For non web applications, this method sets a [ThreadStatic] variable which stores the 
        id in thread local storage. All HealthVault requests made on this thread will re-use this
        variable