Export (0) Print
Expand All

RetrieveTimestamp Message (MetadataService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Retrieves a time stamp for the metadata.

The relevant classes are specified in the following table.

TypeClass
RequestRetrieveTimestampRequest
ResponseRetrieveTimestampResponse

Remarks

Execute this message before you retrieve metadata. You can repeat this process later to see if the metadata has changed in the intervening time. If the value is the same, the metadata has not changed. If the value is different, you retrieve the metadata again to get the updated values.

To perform this action, the caller must be a user in the organization for which metadata is requested and must have Read Entity privilege.

Example

The following example shows how to use the RetrieveTimestamp message.

[C#]
// Create an authentication token.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.OrganizationName = "AdventureWorksCycle";

// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 

// Create the metadata Web service;
MetadataService metadataService = new MetadataService();
metadataService.Url = "http://<servername>:<port>/MSCRMServices/2007/MetadataService.asmx";
metadataService.CrmAuthenticationTokenValue = token;
metadataService.Credentials = System.Net.CredentialCache.DefaultCredentials;
metadataService.PreAuthenticate = true;

// Create a metadata timestamp request.
RetrieveTimestampRequest timestampRequest = new RetrieveTimestampRequest();

// Execute the request.
RetrieveTimestampResponse timestampResponse = (RetrieveTimestampResponse)metadataService.Execute(timestampRequest);

// Access the retrieved timestamp.
string currentTimestamp = timestampResponse.Timestamp;

// Compare the timestamp with a previously retrieved timestamp.
if (currentTimestamp == initialTimestamp)
{
   // The metadata has not been modified since our initial timestamp was retrieved.
}
else
{
   // The metadata has been modified since our initial timestamp was retrieved.
}
[Visual Basic .NET]
' Set up the CRM service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";

// Create the metadata Web service.
Dim metadataService As New MetadataService ()
metadataService.Url = "http://<servername>:<port>/mscrmservices/2007/MetadataService.asmx";
metadataService.CrmAuthenticationTokenValue = token;
metadataService.Credentials = System.Net.CredentialCache.DefaultCredentials
metadataService.PreAuthenticate = true;

' Create a metadata timestamp request.
Dim timestampRequest As New RetrieveTimestampRequest()

' Execute the request.
Dim timestampResponse As RetrieveTimestampResponse = CType(metadataService.Execute(timestampRequest), RetrieveTimestampResponse)

' Access the retrieved timestamp.
Dim currentTimestamp As String = timestampResponse.Timestamp

' Compare the timestamp with a previously retrieved timestamp.
If currentTimestamp = initialTimestamp Then
   ' The metadata has not been modified since our initial timestamp was retrieved.
Else
   ' The metadata has been modified since our initial timestamp was retrieved.
End If

See Also

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft