Accessing Audit Information - Source, Create/Update Timestamp

Nov 4, 2010 at 6:35 PM


In our application, we are looking to maintain an audit trail of information about the records that are obtained from Microsoft HealthVault. Here are some of the information that we are looking for currently

1. Source of the information - The <source> tag is available in the XML. But how can I access it through JAXB API?

2. Timestamp (Create/Update) - The Thing.getCreated() and Thing.getUpdated() methods that are available in the Thing object - is always null - so I cannot seem to to be able to retrieve the create date/time stamp.

Can you please help me with this?



Nov 8, 2010 at 11:04 PM
Edited Nov 9, 2010 at 12:24 AM

Hi Shyam,

Sorry for the delay.  For some reason I didn't see your post.

You are right that the timestamps aren't coming back.  There are two things here (one my fault):

  • you need to add the following code in order to return audit information


  • I need to upgrade to GetThings version 2 which added the Create audit.  It looks like the GetThings method is coded to declare version 1.  I'll fix that tonight.



Nov 9, 2010 at 2:48 AM

Hi Shyam,

If you are still interested, I checked in the change to use version 2 of GetThings.  You should be able to obtain the Create Audit history now. 


Nov 9, 2010 at 7:34 AM
Edited Nov 9, 2010 at 7:35 AM

I forgot to add that the source is available from the Thing.


Most things will not have source set.  Most things probably won't have a Common section either, so both can be null.

Nov 9, 2010 at 4:17 PM


I just downloaded the new set of source files and i am trying to build the file - and I got the following error. I ran "mvn install" from "hv-sdk" folder.

[INFO] Scanning for projects...

[ERROR] The build could not read 2 projects -> [Help 1][ERROR]  

 [ERROR]   The project hv:weight-jaxb-ui:1.1-SNAPSHOT (C:\BCBSFL\hv\hv-sdk\examples\ui-jaxb\pom.xml) has 1 error

[ERROR]    Non-resolvable parent POM: Could not find artifact and 'parent.relativePath' points at wrong local POM @ line 10, column 11 -> [Help 2][ERROR]

 [ERROR]   The project (C:\BCBSFL\hv\hv-sdk\examples\ui-sdk\pom.xml) has 1 error

[ERROR]     Non-resolvable parent POM: Could not find artifact and 'parent.relativePath' points at wrong local POM @ line 28, column 13 -> [Help 2][ERROR]

 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR]

 [ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1][ERROR] [Help 2]


Hope you can help.


Nov 9, 2010 at 9:00 PM

I checked out the source on a clean machine, cleared my repository and it built fine.  What version of maven are you using?

Nov 9, 2010 at 9:04 PM

I am using Maven 3.0 - may be i shud use 2.2 ?

Nov 9, 2010 at 9:40 PM

Works with Maven 2.2.1 - not sure what is the problem when i use 3.0. But thanks for your help.

Nov 9, 2010 at 11:03 PM

Thanks.  I'll see what the deal is with Maven 3.

Nov 10, 2010 at 6:21 PM

Hi Rob,

I am not sure if this is a problem with the new JDK - but i get an access is denied exception when i try "GetPersonInfo". This used to work fine when i was using the old version of the hv-sdk.jar file. Any ideas ?

Request request = new Request(); request.setTtl(3600 * 8 + 300);



HVAccessor accessor = new HVAccessor();

accessor.send(request, ConnectionFactory.getConnection());

[11/10/10 12:15:33:066 EST] 00000019 SystemOut     O DEBUG - Connection                 - <wc-request:request xmlns:wc-request=""><header><method>CreateAuthenticatedSessionToken</method><method-version>1</method-version><app-id>3b4f47dc-2d1f-4d6f-bfc3-15cca856b9db</app-id><language>en</language><country>US</country><msg-time>2010-11-10T12:15:33.066-05:00</msg-time><msg-ttl>180000</msg-ttl><version></version></header><info><auth-info><app-id>3b4f47dc-2d1f-4d6f-bfc3-15cca856b9db</app-id><credential><appserver><sig digestMethod="SHA1" sigMethod="RSA-SHA1" thumbprint="4ca512b0b5a5ca3e751e6f92f7a1c1e5ebb0309c">guc/3e9/Zl8kO1WR+G/FI5RoqlerbKhIuMgUghvRn5A5LalfvnWMBkp6bu4AGihvEl37WcD2ZElPKHc6T/UcnM4GhI6JZBcr3/DzXY9dS6SCVQ55CFIeF1Hc2ufhlCGH3TWXXHun8E1SeopSEu8Ee8FRgQkEnN8AM2Cm7pxJphXFswqJSgUrLsASLsIzOSYjnUxhcs9phsad1THwSBffZtiW905/vnZ3pkQWSBtv/p2+SUjUpo3iXnrdoNInSeDebyaXGmAN1qpbXpYfonmyowtjZvbLK9fh2NrUoocOju+cl3+AhWt/15YYns7IUqzgyoJLTLwatgOd3cM8VsFAkg==</sig><content><app-id>3b4f47dc-2d1f-4d6f-bfc3-15cca856b9db</app-id><shared-secret><hmac-alg algName="HMACSHA1">WJ3aq3udmjrMrLwgOATIDd8QvlY=</hmac-alg></shared-secret></content></appserver></credential></auth-info></info>

</wc-request:request>DEBUG - ResponseStrategy           - <?xml version="1.0" encoding="utf-8"?><response><status><code>11</code><error><message>Access is denied.</message></error></status></response>

[11/10/10 12:15:33:554 EST] 00000019 servlet       E service SRVE0068E: Uncaught exception created in one of the service methods of the servlet hv-action in application HealthVaultEAR. Exception created : Access is denied. at at at com.guidewell.pad.prompt.hv.ShellUtils.getSelectedRecordAndPerson( at com.guidewell.pad.prompt.hv.ShellUtils.loginSuccess( at com.guidewell.pad.prompt.hv.HVActionHandler.loginSuccess(


Nov 10, 2010 at 7:04 PM

Thanks for the complete request and response.  It makes debugging easier.

The request fails to authenticate your application to HealthVault.  HealthVault could not find a public key registered for your application with the thumbprint:  4ca512b0b5a5ca3e751e6f92f7a1c1e5ebb0309c.

Ensure that you are using the correct keys in the keystore for this appid.


Nov 11, 2010 at 4:27 PM

I am not sure what exactly - I am doing incorrectly here. I have the latest version of the JDK (1.6.22). I used the keytool to generate the keystore file (as described in the "Getting Started" guide).

I exported the public key (again as described in the "Getting started" guide on this site). I added it to the application public certificates.

Is there something that I am missing here? I exported the public key for the cacerts file from JDK version 1.6.21 though (for SSL). Do I need to recreate the public key with the new version of JDK as well? 

Any ideas?

Nov 11, 2010 at 8:02 PM

What OS are you running on?  Export the certificate from the keystore you think you are using. 

> keytool -export -alias java-wildcat -keystore keystore > my-pub.cer

If you are on Windows, double click the certificate file and select the "Details".  Look at the thumbprint of the certificate and see if it matches the one your application sent in the request above.  Also, check the "Valid to" date and ensure the certificate has not expired.

If you are on something else, openssl is your friend.  Issue the following commands and ensure the thumbprint is the same as you are sending and the Validity dates are within range.

> openssl x509 -fingerprint inform DER < my-pub.cer

> openssl x509 -text inform DER < my-pub.cer

The version of JDK does not matter.  You just need to ensure the certificate is valid, in HealthVault assigned to the right app-id, and you are sending what you think you are sending in the Authentication call.  If you verify everything it will work.  As a last resort, generate a new key pair and assign it to your application at




Nov 12, 2010 at 7:33 PM

Thanks Rob. When I was creating a JAR file with my keystore file it was being overridden by another JAR file (also being created by me). So essentially my keystore file was invalid. But ur comments will certainly help me verify the certificate at a later date when i will most certainly have to face the similar issues :)



Aug 22, 2012 at 9:22 PM
robmay wrote:

I forgot to add that the source is available from the Thing.


Most things will not have source set.  Most things probably won't have a Common section either, so both can be null.

Back to the original topic of this forum thread :-)

"Most things will not have source set". Is that still true? If my app creates, say, a Medication Record in the sandbox, then retrieves it, should it have the source as null or should it contain the Application ID? I think a case could be made for it being the App ID :-) but it seems to come out as null.  My code is based on your one-liner above. We have our own app-specific model classes, and where we convert from the library classes to our own, I added the getSource() call above, resulting in the following high-speed collision: medicationThing = ( thing.getData();
Medication medication = new Medication();
medication.copy(medicationThing); // fills most values
final Common common = thing.getDataXml().get(0).getCommon();
if (common != null) {
	final String source = common.getSource();

Am I doing something wrong, or is value null in the database, or is the library not doing the right thing?



Aug 23, 2012 at 8:30 PM

Further to my own query, I see in dumping the raw XML that the information I want is in there. In the response to the query I see this:


<response><status><code>0</code></status><wc:info xmlns:wc=""><group>

<thing><thing-id version-stamp="b4e446a8-...">9f78c58c-...</thing-id>

<type-id name="Daily Medication Usage">...

... <created><timestamp>2012-08-23T17:20:37.023Z</timestamp><app-id name="MyAppNameHere">42febf0d-...</app-id>...

Should this not get passed through as the "source" of the event? Is there a good (or a quick) way to access it directly?


Thanks Rob! (Or anyone else with the answer)

Aug 23, 2012 at 8:50 PM

D'OH! Now I get it - the appid DOES come out - it comes out as part of the Audit object!

For the record, ie., for anyone else that needs it, here is the code to get the app id from the Created (or Updated) fields:

final Audit audit = thing.getCreated(); // or getUpdated()
final GuidAndName appId = audit.getAppId();
System.out.printf("App name %s, guid %s%n", 
    appId.getName(), appId.getValue());

Don't you wish all the questions answered themselves? I guess that's reason enough to mull on them before you answer them :-)

Sep 6, 2012 at 3:40 PM

I like questions that answer themselves.  ;-)  Thanks for digging!