HealthServiceRequest HealthServiceRequest HealthServiceRequest Class


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

public class HealthServiceRequest
type HealthServiceRequest = class
    interface IEasyWebResponseHandler
Public Class HealthServiceRequest


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.


HealthServiceRequest(HealthServiceConnection, String, Int32) HealthServiceRequest(HealthServiceConnection, String, Int32) HealthServiceRequest(HealthServiceConnection, String, Int32)

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

HealthServiceRequest(HealthServiceConnection, String, Int32, HealthRecordAccessor) HealthServiceRequest(HealthServiceConnection, String, Int32, HealthRecordAccessor) HealthServiceRequest(HealthServiceConnection, String, Int32, HealthRecordAccessor)

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


CultureCode CultureCode CultureCode

Gets or sets the culture-code for the request.

ImpersonatedPersonId ImpersonatedPersonId ImpersonatedPersonId

Gets or sets the identifier of the person being impersonated.

MethodName MethodName MethodName

Gets or sets the method name to call.

MethodVersion MethodVersion MethodVersion

Gets or sets the version of the method to call.

Parameters Parameters Parameters

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

RecordId RecordId RecordId

Gets or sets the record identifier.

RequestCompressionMethod RequestCompressionMethod RequestCompressionMethod

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

Response Response Response

Gets the response after Execute is called.

ResponseStreamHandler ResponseStreamHandler ResponseStreamHandler

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

TimeoutSeconds TimeoutSeconds TimeoutSeconds

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


BuildRequestXml() BuildRequestXml() BuildRequestXml()

Connects the XML using default values.

BuildRequestXml(String) BuildRequestXml(String) BuildRequestXml(String)

Connects the XML using the specified optional XSL.

CancelRequest() CancelRequest() CancelRequest()

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

Execute() Execute() Execute()

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

ExecuteForTransform(String) ExecuteForTransform(String) ExecuteForTransform(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

GetCorrelationId() GetCorrelationId() GetCorrelationId()

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.

GetLastResponseId() GetLastResponseId() GetLastResponseId()

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.

HandleResponse(Stream, WebHeaderCollection) HandleResponse(Stream, WebHeaderCollection) HandleResponse(Stream, WebHeaderCollection)

Represents the Microsoft.Health.IEasyWebResponseHandler callback.

HandleResponseResult(Stream, WebHeaderCollection) HandleResponseResult(Stream, WebHeaderCollection) HandleResponseResult(Stream, WebHeaderCollection)

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

HandleResponseStream(Stream) HandleResponseStream(Stream) HandleResponseStream(Stream)

Represents the Microsoft.Health.IEasyWebResponseHandler callback.

HandleResponseStreamResult(Stream) HandleResponseStreamResult(Stream) HandleResponseStreamResult(Stream)

Handles the data retrieved by making the web request.

SetCorrelationId(Guid) SetCorrelationId(Guid) SetCorrelationId(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 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

Applies to