Offline access

Jul 31, 2008 at 3:52 PM
I'm working with on a team that is integrating with health vault, and will be using offline access.  After looking a bit through the lib, I'm pretty sure the answer is no, but just to ask -- does the current Java lib have any of the classess needed for offline work?  I notice that there seems to be no OfflineWebApplicationConnection equivilant.  Assuming the answer is no... any suggestions as to the best way we might go about implementing this functionality?  Is there significant differences between the online/offline sdk code?

Thanks,

Duncan
Aug 6, 2008 at 10:50 PM
Edited Aug 6, 2008 at 10:52 PM
You can do offline access w/ the Java libraries by using the XML web-service methods (http://developer.healthvault.com/sdk/docs/index.html).  When using application-level methods like CreateConnectRequest and GetAuthorizedConnectRequests, send the Request object without setting Request.userAuthToken (the authToken generated by ConnectionFactory.getConnection() should be just fine as is); for user-level methods, use Request.setOfflineUserId() to specify the specific user/hv person.  Also, be sure to open up your application id to offline access.

-Layne
Coordinator
Aug 7, 2008 at 12:47 AM
Layne is spot on.  The classes here are pretty thin but the functionality is there.  Higher level abstractions can be built on top of these to provide offline or online specific connection objects.  As it stands, these classes are almost raw interfaces to the request xml. 

As stated above, the only real difference between an offline request and an online request as far as the xml goes is the substitution of an offline-person-id for of the user-auth-token.

--Rob 
Aug 14, 2008 at 9:35 PM
Hello,

I am new on HealthVault. Currently I working on a similar project to integrate our application which will handle the following:

-->authenticate the user when he connects to his Health Vault account through my application.
-->Add the data collected by my application to be stored in Health Vault.

I created Windows Live ID. How do I use this ID to do authentication and upload the data? Could you give me the exact steps to be followed?

Thanks
Jun
Coordinator
Aug 15, 2008 at 12:08 AM
Edited Aug 15, 2008 at 12:09 AM
Jun,

Are you using Java or .Net?  This site provides the libraries and a sample application in Java for doing what you describe.  If you are interested in the Java approach, download the source for these tools and follow the directions here:  http://www.codeplex.com/HealthVaultJavaLib/Thread/View.aspx?ThreadId=30294


Aug 15, 2008 at 2:36 AM
Hi Rob,

I am using Java. I have downloaded libraries and successfully run the example in my workstation. But the example is using web access. I still don't have too much idea how to do the offline access. Do you have any simple example or any document which i can refer?

Thanks
Jun
Coordinator
Aug 15, 2008 at 5:19 AM
Edited Aug 15, 2008 at 5:19 AM
Offline access means that the user has not logged into HealthVault and you do not have a user-auth-token.  Instead of calling request.setUserAuthToken(...) call request.setOfflineUserId(...).  The request sequence goes like this (using PutThings as an example):

Request request = new Request();
request.setMethodName("PutThings");
request.setOfflineUserId(putTheRightUserIdHere);  // Use the user id you stored from a previous GetPersonInfo call
request.setInfo(putTheSerializedInfoHere);

HVAccessor accessor = new HVAccessor();
accessor.send(request, ConnectionFactory.getConnection());

The rest is the same as for online calls.

--Rob
Aug 20, 2008 at 9:44 PM
I tried to use sdk to send out a new weight measurement record by using "PutThings" methode. The request sent out xml like below, but I get a "Access is Denied" response. I have granted all  permission on weight measurement in configuration center.

Anything I missed in Requset?

Thanks for any advice you can provide.

<wc-request:request xmlns:wc-request="urn:com.microsoft.wc.request">
    <auth>
        <hmac-data algName="HMACSHA1">
            tTF4YKXJQVRTjwY683x9muupjzo=
        </hmac-data>
    </auth>
    <header>
        <method>PutThings</method>
        <method-version>1</method-version>
        <record-id>d2df9249-f026-4467-b29d-79990845a6c2</record-id>
        <auth-session>
            <auth-token>
                ASAAAE57vlXwS8VDupO6/FSWlMZLmdMdQucEzxQXYhr9+4fNXUDftpv2gI/MYj6QjIt1ga2JfTMP77OAtV9fOuwSegITK7R2fpLt/8WY1C7RgY/8JSFFd0BJ5su5MR+tVcozRjN4wLF2XlSgK0vABECUlYdpqFRWNv/iYPWrcFpZpwEUZzHqdi7YD1cbUb7S+DCGm3V2Q0n4IopRYoadp5Vkj6oswmuh
            </auth-token>
            <offline-person-info>
                <offline-person-id>
                    b8d3cdfa-ca1c-4eaa-aa20-ef0d71a1f7da
                </offline-person-id>
            </offline-person-info>
        </auth-session>
        <language>en</language>
        <country>US</country>
        <msg-time>2008-08-19T17:08:00.719-04:00</msg-time>
        <msg-ttl>180000</msg-ttl>
        <version>0.0.0.1</version>
        <info-hash>
            <hash-data algName="SHA1">
                BLSLU/dw6ShY/UckpJJTTDEDumE=
            </hash-data>
        </info-hash>
    </header>
    <info>
        <thing>
            <type-id>3d34d87e-7fc1-4153-800f-f56592cb0d17</type-id>
            <data-xml>
                <weight>
                    <when>
                        <date>
                            <y>2008</y>
                            <m>8</m>
                            <d>19</d>
                        </date>
                        <time>
                            <h>17</h>
                            <m>8</m>
                            <s>0</s>
                        </time>
                    </when>
                    <value>
                        <kg>99.99</kg>
                        <display units="lb" units-code="lb">
                            99.99
                        </display>
                    </value>
                </weight>
                <common />
            </data-xml>
        </thing>
    </info>
</wc-request:request>
Coordinator
Aug 21, 2008 at 7:30 PM
Edited Aug 21, 2008 at 7:32 PM
Jun,

Your request looks perfect.  Can you ensure that your application auth rules grant offline access to weight things?  There are two separate rule configurations, one for online (when the user is logged in and you have a user-auth-token) and one for offline (when the user is not logged in and you do not have a user-auth-token). 

Also, if you changed your application auth rules, the user will have to reauthorize your application before you can make any calls for that user and their record.

If you post your application-id we might be able to check for you. 

I'll try and work up an offline sample and post it in the next couple of days.  I'll also be posting an optional library to parse all the requests/responses/types.  Hopefully things will only get easier as we go forward.

--Rob
Aug 21, 2008 at 9:26 PM

Rob -

Moving the conversation from HealthVault forum:http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=3776690&SiteID=1&mode=1 to here.

In addition to above Jun has posted:
"

I am using Java library. I am be able to do "GetAuthorizedConnectRequests" and "CreateConnectRequest". I have tried to do "GetThings", but it failed too. Below is the xml of the response.

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

Thanks
Jun
"

regards,
Vaibhav

 

Aug 21, 2008 at 10:01 PM

hi Jun -

What is the appid you are using? We suspect that it might not have correct offline permissions.

regards,
Vaibhav

Jan 30, 2009 at 6:27 PM
Edited Feb 2, 2009 at 9:56 PM
snip
Coordinator
Feb 4, 2009 at 6:13 AM
mick783 wrote:

> Hello,
> I am trying to make a call to CreateConnectionRequest from the sample web application but I get a HVAccessDeniedException. Should I be able > to do this using the test app or am I missing something here?
        
> Request request = new Request();
> request.setMethodName("CreateConnectRequest");
> request.setInfo("<info><friendly-name>mick783</friendly-name>
> <question>What is your pet's name?</question><answer>Fido</answer><external-id>mick783</external-id></info>");
> HVAccessor accessor = new HVAccessor();
> Connection conn = ConnectionFactory.getConnection();
> accessor.send(request, conn);
> Response response = accessor.getResponse();
> int code = response.getResponseCode();
> System.out.println(code);
>
> Exception in thread "main" com.microsoft.hsg.HVAccessDeniedException
>    at com.microsoft.hsg.DefaultResponseCodeTranslator.translate(DefaultResponseCodeTranslator.java:32)
>    at com.microsoft.hsg.DefaultResponseStrategy.checkResponseCode(DefaultResponseStrategy.java:74)
>    at com.microsoft.hsg.DefaultResponseStrategy.doWithResponse(DefaultResponseStrategy.java:65)
>    at com.microsoft.hsg.HVAccessor$1.send(HVAccessor.java:95)
>    at com.microsoft.hsg.DefaultSendStrategy.doWithSender(DefaultSendStrategy.java:26)
>    at com.microsoft.hsg.HVAccessor.send(HVAccessor.java:91)
>    at com.microsoft.hsg.applications.weight.Test.getConnetionRequest(Test.java:43)
>    at com.microsoft.hsg.applications.weight.Test.main(Test.java:26)
>
> Thanks

The sample application does not have permission to call CreateConnectRequest.  You will have to create your own application.

--Rob

Feb 4, 2009 at 2:20 PM
Thanks

On Wed, Feb 4, 2009 at 1:13 AM, robmay <notifications@codeplex.com> wrote:

From: robmay

mick783 wrote:

> Hello,
> I am trying to make a call to CreateConnectionRequest from the sample web application but I get a HVAccessDeniedException. Should I be able > to do this using the test app or am I missing something here?

> Request request = new Request();
> request.setMethodName("CreateConnectRequest");
> request.setInfo("<info><friendly-name>mick783</friendly-name>
> <question>What is your pet's name?</question><answer>Fido</answer><external-id>mick783</external-id></info>");
> HVAccessor accessor = new HVAccessor();
> Connection conn = ConnectionFactory.getConnection();
> accessor.send(request, conn);
> Response response = accessor.getResponse();
> int code = response.getResponseCode();
> System.out.println(code);
>
> Exception in thread "main" com.microsoft.hsg.HVAccessDeniedException
> at com.microsoft.hsg.DefaultResponseCodeTranslator.translate(DefaultResponseCodeTranslator.java:32)
> at com.microsoft.hsg.DefaultResponseStrategy.checkResponseCode(DefaultResponseStrategy.java:74)
> at com.microsoft.hsg.DefaultResponseStrategy.doWithResponse(DefaultResponseStrategy.java:65)
> at com.microsoft.hsg.HVAccessor$1.send(HVAccessor.java:95)
> at com.microsoft.hsg.DefaultSendStrategy.doWithSender(DefaultSendStrategy.java:26)
> at com.microsoft.hsg.HVAccessor.send(HVAccessor.java:91)
> at com.microsoft.hsg.applications.weight.Test.getConnetionRequest(Test.java:43)
> at com.microsoft.hsg.applications.weight.Test.main(Test.java:26)
>
> Thanks

The sample application does not have permission to call CreateConnectRequest. You will have to create your own application.

--Rob

Read the full discussion online.

To add a post to this discussion, reply to this email (HealthVaultJavaLib@discussions.codeplex.com)

To start a new discussion for this project, email HealthVaultJavaLib@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


May 13, 2009 at 8:50 PM

This information is very helpful but the one step I haven't been able to figure out is how to initially get the userId and recordId when doing Offline access. Can someone outline that process with the java library provided here?

 

Thanks.

Coordinator
May 18, 2009 at 4:42 PM

Most offline applications also have an online component.  When the user authorizes your application, they will be redirected to your app.  At this time, you can store their person-id.  With their person-id, you can call GetPersonInfo in either offline or online mode to get their records. 

Oct 15, 2009 at 2:22 PM

Question: I get the fact that we need to store the person ID and set request.setOfflineUserId()  but don't we also still need to set request.setRecordId(). In online access the record ID comes across in the personInfo we did not have to store it, but for offline don't we also need to store the record ID?

Oct 20, 2009 at 5:24 PM
Edited Oct 20, 2009 at 9:43 PM
robmay wrote:

With their person-id, you can call GetPersonInfo in either offline or online mode to get their records. 

I'm trying to do this, but it's not working.  The response returns an error with a response code of 67 (which I think means "invalid person or group ID") and then it throws a HVUncategorizedException because it doesn't know how to handle that error code.  Can you tell me what I'm doing wrong?

Here's my Java code:

//create request
Request request = new Request();
request.setTtl(3600 * 8 + 300);
request.setMethodName("GetPersonInfo");
request.setOfflineUserId("abcdefgh-0123-4567-8901-ijklmnopqrst");

//send request
Connection connection = ConnectionFactory.getConnection();
HVAccessor accessor = new HVAccessor();
accessor.send(request, connection);


The XML request it sends:

<wc-request:request xmlns:wc-request="urn:com.microsoft.wc.request">
<auth>
<hmac-data algName="HMACSHA1">Ekemx9oH+05/e06EJBwvwOghv/A=</hmac-data>
</auth>
<header>
<method>GetPersonInfo</method>
<method-version>1</method-version>
<auth-session>
<auth-token>**snip**</auth-token>
<offline-person-info>
<offline-person-id>abcdefgh-0123-4567-8901-ijklmnopqrst</offline-person-id>
</offline-person-info>
</auth-session>
<language>en</language>
<country>US</country>
<msg-time>2009-10-20T11:40:29.689-04:00</msg-time>
<msg-ttl>29100</msg-ttl>
<version>0.0.0.1</version>
<info-hash>
<hash-data algName="SHA1">+FS0rMnT//A9dC7u3XviYXiUM24=</hash-data>
</info-hash>
</header>
<info />
</wc-request:request>

 

The XML response it gets back:

<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>
<code>67</code>
<error>
<message>Exception of type
'Microsoft.Health.Platform.WildcatStatusException' was thrown.</message>
</error>
</status>
</response>

 

Note: I've replaced my person-id with a fake one in the above code samples.

Thanks for your help.

 

Coordinator
Oct 22, 2009 at 11:59 PM

mangstadt,

Your request looks good.  Unfortunately your request tickled a bug in the error messaging code and you did not receive the proper message.  It would have said that the person-id was not found.  Be sure you are using the person-id and not a record-id.

--Rob

 

Oct 23, 2009 at 3:26 PM

Thanks for the response, Rob.  Actually, the problem turned out to be that I was using the Person and Record IDs that I got while connected to the sample application, NOT my own application.  I didn't know that they changed between applications.  After calling GetPersonInfo in online mode from my own application, I was able to get the correct IDs.

http://social.msdn.microsoft.com/Forums/en-US/healthvault/thread/a7f0f447-3818-4fb1-b973-cf887dc33f48

Thanks,

-Mike