Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:34:32+00:00 2026-05-30T07:34:32+00:00

I am trying to write an activity to call a WebService, parse the xml

  • 0

I am trying to write an activity to call a WebService, parse the xml response, and return the results as OutArguement. I am struck trying to access the CodeActivityContext from the OpenReadCompletedEventHandler I have set up to parse the xml. Please see below for what I am trying to accomplish, specifically where I am trying to access the activity context (this.OutputType.Set(context, myCollection)) and let me whether this can be done and how to set up correctly. Many thanks for your help.

[CategoryAttribute("Out Arguments")]
        public OutArgument<List<string>> OutputType { get; set; }



protected override void Execute(CodeActivityContext context)
            {
                Uri svcUri = new Uri(@"http://path/to/webservice");
                WebClient svc = new WebClient();
                svc.OpenReadCompleted += new OpenReadCompletedEventHandler(svc_OpenReadCompleted);
                svc.OpenReadAsync(svcUri);
            }


void svc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                Stream responseStream = e.Result;
                parametersXml = XDocument.Load(responseStream);

                // linq to xml to pull out each of the parameter tags and their descendants
                var parameters = from item in parametersXml.Descendants("parameter")
                                 select new myParameter
                                 {
                                     name = item.Element("name").Value,
                                     description = item.Element("description").Value,
                                     defaultValue = item.Element("defaultValue").Value,
                                     optionsType = item.Element("optionsType").Value,
                                     type = item.Element("type").Value,
                                     options = (from ops in item.Descendants("options").Elements()
                                                select new
                                                {
                                                    Key = (string)ops.Element("value").Value,
                                                    Value = ops.Element("displayAlias") != null
                                                    ? (string)ops.Element("displayAlias").Value
                                                    : ""
                                                }).ToDictionary(pair => pair.Key, pair => pair.Value)
                                 };
                foreach (myParameter i in parameters)
                {
                    if (i.name == "DATA_TO_DOWNLOAD")
                    {
                        foreach (string optionKey in i.options.Keys)
                        {
                            myCollection.Add(optionKey);
                        }
                    }
                    this.OutputType.Set(context, myCollection);
                }
            }
            else
            {
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:34:33+00:00Added an answer on May 30, 2026 at 7:34 am

    Please read up on the AsyncCodeActivity in WF4. This will allow you to call an APM (Asynchronous Programming Model, i.e. Beginxxx, Endxxx) method pair from an activity without blocking the scheduler thread.

    The WebClient class uses the EAP (Event Asynchonous Programming) model so does not have a method pair. You can either use the BeginInvoke EndInvoke pair in a wrapped TPL Task or use HttpWebRequest instead of WebClient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a simple activity that received from the user its
I`m trying to parse an object from my my main activity to a new
I'm trying to write a library to separate all the disk activity out into
im trying to write an app that will display a list off lines from
I'm trying to write an app that consists of an activity that manages a
I am trying out Workflow 4.0 and hoping to write a custom activity to
I am trying to write a query for retrieving data from SQLite database. I
I'm trying to write an activity that would be able to both write and
I'm trying to write an XML over HTTP push notification consumer that accepts the
I am trying to write an Activity that has some views, a fillView() method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.