首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Java中调用HealthVault GetThings方法

在Java中调用HealthVault GetThings方法
EN

Stack Overflow用户
提问于 2009-10-22 00:56:36
回答 2查看 1.2K关注 0票数 0

我尝试使用Java HealthVault API在“脱机”模式下调用GetThings方法(即用户不必登录),以检索所有"File“类型的项。据我所知,发出离线请求所需的只是用户帐户的Persion ID和记录ID。但是,即使我将这些添加到请求中,方法调用也不起作用。在响应中返回错误码"67“,根据API中的一个静态变量,该错误码代表”无效的个人或组ID“。

我仔细检查了个人ID和记录ID,它们确实是正确的。在“在线”模式下发出相同的请求(即包含user-auth-token时)工作得很好。我的应用程序被配置为允许对所有“文件”项类型的离线访问,所以它不会成为访问问题。

出于安全考虑,我在下面的代码示例中用假ID替换了真实的人员ID和记录ID:

下面是我的Java代码:

代码语言:javascript
复制
StringBuilder requestXml = new StringBuilder();
requestXml.append("<info><group>");
requestXml.append("<filter><type-id>bd0403c5-4ae2-4b0e-a8db-1888678e4528</type-id></filter>");
requestXml.append("<format><section>core</section><section>otherdata</section><xml/></format>");
requestXml.append("</group></info>");

Request request = new Request();
request.setMethodName("GetThings");
request.setOfflineUserId("e2f925e7-2748-4d88-bz48-32036dc10020");
request.setRecordId("73ab2792-5481-43eb-837c-67d1e3337300");
request.setInfo(requestXml.toString());

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

它生成的XML请求:

代码语言:javascript
复制
<wc-request:request xmlns:wc-request="urn:com.microsoft.wc.request">
    <auth>
        <hmac-data algName="HMACSHA1">5WdiBnTvxsNbVHg134ggIETlJNE=</hmac-data>
    </auth>
    <header>
        <method>GetThings</method>
        <method-version>1</method-version>
        <record-id>73ab2792-5481-43eb-837c-67d1e3337300</record-id>
        <auth-session>
            <auth-token>ASAAAJQ1R50J8HpMshAjeHkjh/habVgM17BjSBuA/GmbJPV9A9d63mramakSZxf+ZHZh+7xWllTWGhAijBvxhNxauzBLci1IWWh+JDbGQZabnWbG7YH28ZP+FQuRPNP4T8O1NTNCFNETao0ly+UuPjWEZWCV5cCPX7GjaEJ4BMAFv4vAOEwIOe63VWntfzH9r3Rz0VnHAhb400iqs1XxlJrRbgXdNRdg</auth-token>
            <offline-person-info>
                <offline-person-id>e2f925e7-2748-4d88-bz48-32036dc10020</offline-person-id>
            </offline-person-info>
        </auth-session>
        <language>en</language>
        <country>US</country>
        <msg-time>2009-10-21T12:37:51.706-04:00</msg-time>
        <msg-ttl>180000</msg-ttl>
        <version>0.0.0.1</version>
        <info-hash>
            <hash-data algName="SHA1">oAZVXLGAUMfuVPrqjqb98yCb4/c=</hash-data>
        </info-hash>
    </header>
    <info>
        <group>
            <filter>
                <type-id>bd0403c5-4ae2-4b0e-a8db-1888678e4528</type-id>
            </filter>
            <format>
                <section>core</section>
                <section>otherdata</section>
                <xml />
            </format>
        </group>
    </info>
</wc-request:request>

我得到的XML响应如下:

代码语言:javascript
复制
<?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>

非常感谢你的帮助。:)

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-10-23 22:30:03

原来问题是我的个人ID和记录ID实际上是不正确的。我使用的是连接到示例应用程序时获得的应用程序,而不是我自己的应用程序。我不知道它们会在不同的应用程序中发生变化。在从我自己的应用程序调用GetPersonInfo之后,我能够获得正确的人员ID和记录ID。

票数 0
EN

Stack Overflow用户

发布于 2009-10-22 01:39:20

另一个人通过这样做解决了这个错误。你已经试过了?

代码语言:javascript
复制
I got the error cleared up. I re-imported the certificate (found in the cert
folder) through the Healthvault Application Manager, cleared up the offline.txt
file and re-ran the application.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1602156

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档