2009-10-21 56 views
0

我試圖使用Java HealthVault API以「脫機」模式(即用戶不必登錄)調用GetThings方法來檢索所有「文件」類型項目。根據我的理解,您需要提出離線請求的是用戶帳戶的Persion ID和記錄ID。但是,即使我將這些添加到請求,方法調用不起作用。它在響應中返回錯誤代碼「67」,根據API中的靜態變量,它代表「無效人員或組ID」。調用Java中的HealthVault GetThings方法

我已經雙重檢查了人員ID和記錄ID,他們確實是正確的。在「在線」模式下(即在包含用戶身份驗證令牌時)發出相同的請求完全正常。我的應用程序配置爲允許離線訪問所有「文件」項目類型,因此它不能成爲訪問問題。

我已經取代了真正的人的ID和記錄ID用假的下面的代碼示例中出於安全原因:

這裏是我的Java代碼:

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請求時,它產生:

<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響應我回去:

<?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> 

非常感謝您的幫助。 :)

回答

0

原來,問題是,我個人並記錄ID實際上不正確。我使用的是我在連接到示例應用程序時獲得的應用程序,而不是我的自己的應用程序。我不知道他們改變了應用程序。在從我自己的應用程序調用GetPersonInfo後,我能夠獲得正確的人員和記錄標識。

1

一些其他人通過這樣做解決了錯誤。你已經嘗試過了嗎?

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. 
+0

感謝您的建議。這聽起來像是他的證書問題。我嘗試重新創建我的密鑰庫(我正在使用Java ......他可能使用了.NET),但這並沒有幫助。我使用相同的密鑰存儲「在線」模式,並沒有問題。 – Michael 2009-10-21 18:17:34