locked
Error when try to create child application id using Provisioner.AddApplication() method RRS feed

  • Question

  • Here is the sampe code and error I am receiving, while trying to create child application



    string
    appid = WebConfigurationManager.AppSettings["ApplicationId"];

     

    OfflineWebApplicationConnection owac = new OfflineWebApplicationConnection(new Guid(appid), WebConfigurationManager.AppSettings["HealthServiceUrl"] + "wildcat.ashx", Guid.Empty);

    owac.Authenticate();

     

    Guid childappid = Guid.Empty;

     

    ApplicationInfo childapp = new ApplicationInfo();

     

    // Get the master application certificate

     

    string master_certname = "WildcatApp-" + appid;

     

    X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

     

    StorePermission sp = new StorePermission(PermissionState.Unrestricted);

    sp.Flags =

    StorePermissionFlags.OpenStore;

    sp.Assert();

     

    X509Certificate2 cert2 = null;

    store.Open(

    OpenFlags.MaxAllowed);

     

    if (master_certname.Length > 0)

    {

     

    foreach (X509Certificate2 cert in store.Certificates)

    {

     

    if (cert.SubjectName.Name.Contains(master_certname))

    {

    cert2 = cert;

     

    break;

    }

    }

    childapp.PublicKeys.Add(cert2.GetRawCertData());

    childapp.Name =

    "Test Child App";

    childapp.AuthorizationReason =

    "I really, really want it";

    childapp.Description =

    "Test Child Application";

    childapp.DomainName =

    "localhost";

    childapp.LargeLogo =

    new ApplicationBinaryConfiguration(@"C:\Program Files\Microsoft HealthVault\SDK\DotNet\WebSamples\OfflineAccess\website\UnknownSource.png", "Image");

    childapp.PrivacyStatement =

    new ApplicationBinaryConfiguration(new MemoryStream(UTF8Encoding.Default.GetBytes("Everything is secret")), "text");

    childapp.TermsOfUse =

    new ApplicationBinaryConfiguration(new MemoryStream(UTF8Encoding.Default.GetBytes("Abuse is strictly prohibited")), "text");

    childapp.ActionUrl =

    new Uri("http://localhost/redirect.aspx");

    childapp.ConfigurationOptions =

    ApplicationOptions.Default;

     

    List<AuthorizationSetDefinition> authsetDefinition = new List<AuthorizationSetDefinition>();

    authsetDefinition.Add(

    new TypeIdSetDefinition(Microsoft.Health.ItemTypes.Basic.TypeId));

    authsetDefinition.Add(

    new TypeIdSetDefinition(Microsoft.Health.ItemTypes.ApplicationSpecific.TypeId));

    Microsoft.Health.

    AuthorizationRule authrule = new Microsoft.Health.AuthorizationRule(HealthRecordItemPermissions.All, authsetDefinition, new List<AuthorizationSetDefinition>());

    childapp.OfflineBaseAuthorizations.Add(authrule);

    childapp.ConfigurationOptions =

    ApplicationOptions.None;

    childappid =

    Provisioner.AddApplication(owac, childapp);

     

     

    OfflineWebApplicationConnection childowac = new OfflineWebApplicationConnection(childappid, WebConfigurationManager.AppSettings["HealthServiceUrl"] + "wildcat.ashx", Guid.Empty);

    childowac.Authenticate();




    The application does not have permission to call the specified method.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Microsoft.Health.HealthServiceAccessDeniedException: The application does not have permission to call the specified method.

    Source Error:

    Line 66:             childapp.OfflineBaseAuthorizations.Add(authrule);
    Line 67:             childapp.ConfigurationOptions = ApplicationOptions.None;
    Line 68:             childappid = Provisioner.AddApplication(owac, childapp);
    Line 69: 
    Line 70: 
    Friday, November 13, 2009 2:09 PM

Answers

  • Only master applications can create child applications.  By default application ids wont have master application capablity

    You need to navigate to the "Misc" tab in application configuration for the above applcation id, and choose the "Master" radio button.  Wait for 30 mts, and then try the call again
    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    • Marked as answer by Suresh Thakur Monday, November 16, 2009 11:56 AM
    Friday, November 13, 2009 2:33 PM
  • Yes, it is true that you may have to wait upto 30 mts for the config changes that you make to take effect.
    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    • Marked as answer by Suresh Thakur Monday, November 16, 2009 11:56 AM
    Monday, November 16, 2009 7:07 AM

All replies

  • Only master applications can create child applications.  By default application ids wont have master application capablity

    You need to navigate to the "Misc" tab in application configuration for the above applcation id, and choose the "Master" radio button.  Wait for 30 mts, and then try the call again
    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    • Marked as answer by Suresh Thakur Monday, November 16, 2009 11:56 AM
    Friday, November 13, 2009 2:33 PM
  • Hi Rajesh,

    Thanks !!!

    The code is working fine now. I had configured the application as Master, but I was not aware that I had to wait 30 min to get new config changes.

    Is that true now, that whenever I will make changes in application configuration like app rules, I have to wait 30 min each time to see the new config settings?

    Thanks once again.

    Suresh Thakur
    Monday, November 16, 2009 5:17 AM
  • Yes, it is true that you may have to wait upto 30 mts for the config changes that you make to take effect.
    Raj HealthVault Developer Tool http://xray.getrealconsulting.com
    • Marked as answer by Suresh Thakur Monday, November 16, 2009 11:56 AM
    Monday, November 16, 2009 7:07 AM
  • Thanks for the clarification.!!!

    Thanks and Regards
    Suresh Thakur
    Monday, November 16, 2009 11:57 AM