none
ArgumentNullException when trying to exec ReadResourceActivity

    Question

  • I have the following Sub-Workflow activity that is included in the other workflows for Creating, Updating and Deleting a SP connection.  It runs if no STS is defined for a Service (if one is defined, everything work correctly).   When it runs, I get this error – “Microsoft.ResourceManagement.WorkflowDataExchangeException: Microsoft.ResourceManagement.WebServices.Exceptions.UnwillingToPerformException: Other ---> System.ArgumentException: Invalid object identifier specified for Get Operation” even though the ObjectID is correct.  What I'm trying to do is walk a hierarchy of organizations until I find a STS. If I set a break point on the InitialzeReadOrginization the OrginizationID is correct, but the workflow still throws the exception (thinks its null ?).

    So what I'm trying to dois if the STS is null for the Org, then I look at the parent org to see if there is one defined - and so on - walking a hirearchy.  - thanks in advance.....

    vendredi 5 avril 2013 22:34

Réponses

  • Something like this:

                SequenceActivity currentParentSequenceActivity = (SequenceActivity)((CodeActivity)sender).Parent;            ReadResourceActivity currentReadActivity = currentParentSequenceActivity.Activities.OfType<ReadResourceActivity>().First();




    Tomek Onyszko, memberOf Predica FIM Team (http://www.predica.pl), IdAM knowledge provider @ http://blog.predica.pl

    • Marqué comme réponse joeb110 dimanche 7 avril 2013 22:49
    dimanche 7 avril 2013 20:56
  • So if I understand correctly, the code would have to look like this -

            private void InitilizeReadOrganization_ExecuteCode(object sender, EventArgs e)
            {
                SequenceActivity currentParentSequenceActivity = (SequenceActivity)((CodeActivity)sender).Parent;
                ReadResourceActivity currentReadActivity = currentParentSequenceActivity.Activities.OfType<ReadResourceActivity>().First();
    
                // Set the Actor ID to the FIM Admin Account GUID
                currentReadActivity.ActorId = new Guid(SubActivities.FIMAdminGuid);
    
                // Set the Resource to the currently requested object.
                currentReadActivity.ResourceId = OrganizationReference.GetGuid();
                // Set the slection paramters
                currentReadActivity.SelectionAttributes = new string[] {"OrganizationReference",
                                                                        "STSReference"                                                                
                                                                       };
            }
    
            private void GetSTSReference_ExecuteCode(object sender, EventArgs e)
            {
                SequenceActivity currentParentSequenceActivity = (SequenceActivity)((CodeActivity)sender).Parent;
                ReadResourceActivity currentReadOrganization = currentParentSequenceActivity.Activities.OfType<ReadResourceActivity>().First();
    
                // Get the object that was read using the Read Activity into a ResourceType object
                if (currentReadOrganization.Resource != null)
                {
                    ResourceType organization = currentReadOrganization.Resource;
                    OrganizationReference = organization["OrganizationReference"] as UniqueIdentifier;
                    STSReference = organization["STSReference"] as UniqueIdentifier;
    
                    if ((OrganizationReference == null) || (STSReference != null))
                    {
                        stsEndWhile = true;
                    }
                }
                else
                {
                    // Did not find an STS
                    stsEndWhile = true;
                }
    

    • Marqué comme réponse joeb110 dimanche 7 avril 2013 22:45
    dimanche 7 avril 2013 22:31

Toutes les réponses

  • To solve this you will have to show us your code for InitilizeRedOrganization. My bet is that in this code you are setting ObjectId directly on ReadOrganization activity - which is not the activity which actually is used. when you are using activity like While for each While loop pass there is separate instance of workflow spanned, and your designer flow is just a "template" how these should look like. At the runtime time you need in your code for InitializeReadOrganization get ReadActivity instance from current workflow and then set all attributes for Read on it as well. Same will be for GetSTSReference.

    Get your parent sequence activity:

    (SequenceActivity)currentActivity.Parent

    And then find first activity of type ReadResourceActivity in this sequence. 


    Tomek Onyszko, memberOf Predica FIM Team (http://www.predica.pl), IdAM knowledge provider @ http://blog.predica.pl

    samedi 6 avril 2013 21:33
  • yes, so it is exactly the case I wrote about - you need to set these on the current workflow instance copy of ReadResources

    Tomek Onyszko, memberOf Predica FIM Team (http://www.predica.pl), IdAM knowledge provider @ http://blog.predica.pl

    dimanche 7 avril 2013 19:31
  • Ok, and how does one do so?  Don't seem to undersatnd the exact syntax to do this.

    To get the Parent sequence activity, do I do  this.Parent and then find an activity that's typeof(ReadRedource) ?

    Sorry, but I'm just a newbie trying to understand this and seems to not be trvial.

    Any help would be greatly appreciated .

    Thanks

    dimanche 7 avril 2013 20:04
  • Something like this:

                SequenceActivity currentParentSequenceActivity = (SequenceActivity)((CodeActivity)sender).Parent;            ReadResourceActivity currentReadActivity = currentParentSequenceActivity.Activities.OfType<ReadResourceActivity>().First();




    Tomek Onyszko, memberOf Predica FIM Team (http://www.predica.pl), IdAM knowledge provider @ http://blog.predica.pl

    • Marqué comme réponse joeb110 dimanche 7 avril 2013 22:49
    dimanche 7 avril 2013 20:56
  • So if I understand correctly, the code would have to look like this -

            private void InitilizeReadOrganization_ExecuteCode(object sender, EventArgs e)
            {
                SequenceActivity currentParentSequenceActivity = (SequenceActivity)((CodeActivity)sender).Parent;
                ReadResourceActivity currentReadActivity = currentParentSequenceActivity.Activities.OfType<ReadResourceActivity>().First();
    
                // Set the Actor ID to the FIM Admin Account GUID
                currentReadActivity.ActorId = new Guid(SubActivities.FIMAdminGuid);
    
                // Set the Resource to the currently requested object.
                currentReadActivity.ResourceId = OrganizationReference.GetGuid();
                // Set the slection paramters
                currentReadActivity.SelectionAttributes = new string[] {"OrganizationReference",
                                                                        "STSReference"                                                                
                                                                       };
            }
    
            private void GetSTSReference_ExecuteCode(object sender, EventArgs e)
            {
                SequenceActivity currentParentSequenceActivity = (SequenceActivity)((CodeActivity)sender).Parent;
                ReadResourceActivity currentReadOrganization = currentParentSequenceActivity.Activities.OfType<ReadResourceActivity>().First();
    
                // Get the object that was read using the Read Activity into a ResourceType object
                if (currentReadOrganization.Resource != null)
                {
                    ResourceType organization = currentReadOrganization.Resource;
                    OrganizationReference = organization["OrganizationReference"] as UniqueIdentifier;
                    STSReference = organization["STSReference"] as UniqueIdentifier;
    
                    if ((OrganizationReference == null) || (STSReference != null))
                    {
                        stsEndWhile = true;
                    }
                }
                else
                {
                    // Did not find an STS
                    stsEndWhile = true;
                }
    

    • Marqué comme réponse joeb110 dimanche 7 avril 2013 22:45
    dimanche 7 avril 2013 22:31
  • Tomasz,

    Thank you so much.  This is indeed the answer and I was lost until you pointed it out to me and helped with the syntax.  I was really at sea and didn't know what portion of my code needed to change of what the proper synsax was. Your code snip-it real opened my eyes and now everything is working as expected.  I owe you a debt of gratitude.

    Onec again - thank you.

    dimanche 7 avril 2013 22:49