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 7061697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:30:20+00:00 2026-05-28T04:30:20+00:00

I am integrating with a REST service and so far so good. Hit a

  • 0

I am integrating with a REST service and so far so good.
Hit a little bit of a hurdle.
I am hitting the service via a HttpWebRequest.
I am receiving responses successfully, but in running the HttpWebResponse GetResponseStream through a StreamReader, i am getting back an

<int xmlns="http://schemas.microsoft.com/2003/10/Serialization/">427</int>.

A little stuck on how to convert this back to a c# int.

Any advice?

Thanks.

  • 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-28T04:30:21+00:00Added an answer on May 28, 2026 at 4:30 am

    You may take a look at the int.Parse and int.TryParse methods in conjunction with a XDocument which you could use to load the response XML into:

    var request = WebRequest.Create(...);
    ...
    using (var response = request.GetResponse())
    using (var stream = response.GetStream())
    {
        var doc = XDocument.Load(stream);
        if (int.TryParse(doc.Root.Value, out value))
        {
    
            // the parsing was successful => you could do something with
            // the integer value you have just read from the body of the response
            // assuming the server returned the XML you have shown in your question,
            // value should equal 427 here.
        }
    }
    

    or even easier, the Load method of XDocument understands HTTP, so you could even do this:

    var doc = XDocument.Load("http://foo/bar");
    if (int.TryParse(doc.Root.Value, out value))
    {
        // the parsing was successful => you could do something with
        // the integer value you have just read from the body of the response
        // assuming the server returned the XML you have shown in your question,
        // value should equal 427 here.
    }
    

    this way you don’t even need to use any HTTP requests/responses. Everything will be handled for you by the BCL which is kinda great.

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

Sidebar

Related Questions

I'm using Adobe AIR and integrating with the force.com platform via the REST API,
I am encountering an error during integrating enunciate and ant for CXF REST service
I am trying to post to a REST service using PHP cURL but I'm
I am trying to run integration tests against a REST web service process that
I'm writing an integration between Salesforce.com and another service, and I've hit a problem
I'm writing a simple REST service in Node.js (just experimenting), trying to figure out
I have a WCF REST service. I would like to write integration tests for
I have a Spring app which launches a REST Service within an embedded instance
I developed a WCF Rest service to post as add-on on Heroku. I haven't
While creating a simple client for a REST service which I have stubbed out,

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.