locked
WebApplicationConnection.GetPersonInfo is leading to exception RRS feed

  • Question

  • My attempt to get PersonInfo object from webApplicationConnection is resulting in following exception:

     

    Exception at :04-01-2008 01:27:13 Description :  StackTrace :   at Microsoft.Health.EasyWebRequest.WaitForCompletion()
       at Microsoft.Health.EasyWebRequest.Fetch(Uri url)
       at Microsoft.Health.EasyWebRequest.Fetch(Uri url, IEasyWebResponseHandler customHandler)
       at Microsoft.Health.HealthServiceRequest.ExecuteInternal()
       at Microsoft.Health.AuthenticatedConnection.ExecuteRequestWithRetry(HealthServiceRequest request)
       at Microsoft.Health.HealthServiceRequest.Execute()
       at Microsoft.Health.AuthenticatedConnection.GetPersonInfo()

     

     

    I am using following lines of code to get the Person info object.

     

    -------------------------------------------------------------------------------------------------------------------------------

    Guid phmsAppGuid = new System.Guid(ConfigurationManager.AppSettings.Get("ApplicationId"));

    Credential credential = new WebApplicationCredential(phmsAppGuid, ticket);

    WebApplicationConnection webConnection = new WebApplicationConnection(credential);

    PersonInfo information = webConnection.GetPersonInfo();

    -------------------------------------------------------------------------------------------------------------------------------

     

    Any clues on what is wrong here ?

     

    I am using Windows Vista + Visual Studio 2005 + IE7

    Thursday, January 3, 2008 8:23 PM

Answers

  • If you use a page that is derived from HealthServicePage, that page will provide all the hookup logic necessary to connect to HealthVault. You can then use PersonInfo to get the person info.

     

    Hope that helps

    Friday, January 4, 2008 10:28 PM
  • Where are you getting "ticket"?  I suspect that you might be using the application token rather than the user token when constructing the WebApplicationCredential.

     

    Here is some test code I have that transfers the credential token to a new connection instance.

     

    WebApplicationCredential cred = (WebApplicationCredential)base.GetAuthenticatedPersonInfo().Connection.Credential;

    String authToken = cred.SubCredential;

    WebApplicationCredential newCred = new WebApplicationCredential(LiveServiceTestBase.TestAppId, authToken);

    AuthenticatedConnection connection =

    new AuthenticatedConnection(

    LiveServiceTestBase.TestAppId,

    base.CommonAuthenticatedConnection.RequestUrl,

    newCred);

    connection.Authenticate();

    connection.GetPersonInfo();

     

     

    Here you can see that the user's auth token that is used to create the WebApplicationCredential is the SubCredential of an existing WebApplicationCredential.

     

    Can you elaborate on your scenario that requires you to do this?  Maybe its something we can provide better support for.

     

    Jeff Jones

    Friday, January 4, 2008 11:00 PM
  • The URL is incorrect.  Can you use Microsoft.Health.ApplicationConfiguration.HealthServiceUrl instead of using ConfigurationManager directly?

     

    Jeff Jones

     

    Friday, January 18, 2008 10:21 PM
  • I found the answer for it from the post before.

    The Service URL we are using is not complete which should be "https://platform.microsofthealthbeta.com/platform/wildcat.ashx" VS "https://platform.microsofthealthbeta.com/platform/" we are using currently.

    It works fine after I changed the service URL.
    Tuesday, January 22, 2008 1:11 AM
  • Sorry.  I had meant for you to use Microsoft.Health.Web.WebApplicationConfiguration.HealthServiceUrl.

     

    Jeff Jones

    Wednesday, January 23, 2008 5:31 PM

All replies

  • If you use a page that is derived from HealthServicePage, that page will provide all the hookup logic necessary to connect to HealthVault. You can then use PersonInfo to get the person info.

     

    Hope that helps

    Friday, January 4, 2008 10:28 PM
  • Where are you getting "ticket"?  I suspect that you might be using the application token rather than the user token when constructing the WebApplicationCredential.

     

    Here is some test code I have that transfers the credential token to a new connection instance.

     

    WebApplicationCredential cred = (WebApplicationCredential)base.GetAuthenticatedPersonInfo().Connection.Credential;

    String authToken = cred.SubCredential;

    WebApplicationCredential newCred = new WebApplicationCredential(LiveServiceTestBase.TestAppId, authToken);

    AuthenticatedConnection connection =

    new AuthenticatedConnection(

    LiveServiceTestBase.TestAppId,

    base.CommonAuthenticatedConnection.RequestUrl,

    newCred);

    connection.Authenticate();

    connection.GetPersonInfo();

     

     

    Here you can see that the user's auth token that is used to create the WebApplicationCredential is the SubCredential of an existing WebApplicationCredential.

     

    Can you elaborate on your scenario that requires you to do this?  Maybe its something we can provide better support for.

     

    Jeff Jones

    Friday, January 4, 2008 11:00 PM
  • I tried to run your sample code aboce, everything is fine except the final step "connection.GetPersonInfo()" which threw an error saying System.Net.WebException: The remote server returned an error: (405) Method Not Allowed.

    I paste the code I used here for your reference.

    WebApplicationCredential cred = (WebApplicationCredential)this.PersonInfo.Connection.Credential;
            String authToken = cred.SubCredential;
            WebApplicationCredential newCred = new WebApplicationCredential(new Guid(ConfigurationManager.AppSettings["ApplicationId"]), authToken);
            AuthenticatedConnection connection =
                new AuthenticatedConnection(
                    new Guid(ConfigurationManager.AppSettings["ApplicationId"]),
                    ConfigurationManager.AppSettings["HealthServiceUrl"],
                    newCred);
            connection.Authenticate();
            Microsoft.Health.PersonInfo person = connection.GetPersonInfo();

    Could you tell me where is the error coming from? And can you post out a workable solution for this issue?

    Kane
    Friday, January 18, 2008 9:13 PM
  • The URL is incorrect.  Can you use Microsoft.Health.ApplicationConfiguration.HealthServiceUrl instead of using ConfigurationManager directly?

     

    Jeff Jones

     

    Friday, January 18, 2008 10:21 PM
  • It happened that Microsoft.Health.ApplicationConfiguration is a protected class which I cannot directly access, is there any way to use it?

     

    I attach here the error message:

     

    Error 102 'Microsoft.Health.ApplicationConfiguration' is inaccessible due to its protection level C:\KWang\Project\HC\Sandbox.aspx.cs 33 34 C:\...\HC\

    Friday, January 18, 2008 11:12 PM
  • I found the answer for it from the post before.

    The Service URL we are using is not complete which should be "https://platform.microsofthealthbeta.com/platform/wildcat.ashx" VS "https://platform.microsofthealthbeta.com/platform/" we are using currently.

    It works fine after I changed the service URL.
    Tuesday, January 22, 2008 1:11 AM
  • Sorry.  I had meant for you to use Microsoft.Health.Web.WebApplicationConfiguration.HealthServiceUrl.

     

    Jeff Jones

    Wednesday, January 23, 2008 5:31 PM