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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:34:10+00:00 2026-05-13T05:34:10+00:00

There is a local service from which I need to consume a generated XML

  • 0

There is a local service from which I need to consume a generated XML Document Stream. Though the end point is not a REST service per se. I wanted to be sure the method I’ve outlined below is the most efficient way of getting the response returned into an XDocument.

Uri requestUri = null;
Uri.TryCreate(String.Format(SearchAddress, filter),
    UriKind.Absolute, out requestUri);

NetworkCredential nc =
    new NetworkCredential("Login", "Password");
CredentialCache cCache = new CredentialCache();
cCache.Add(requestUri, "Basic", nc);

HttpWebRequest request =
    (HttpWebRequest)HttpWebRequest.Create(requestUri);
request.Credentials = cCache;
request.PreAuthenticate = true;
request.Method = WebRequestMethods.Http.Get;

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
XDocument xDoc =
    XDocument.Load(new StreamReader(response.GetResponseStream()));
  • 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-13T05:34:10+00:00Added an answer on May 13, 2026 at 5:34 am

    If you want a synchronous request then in my opinion yes it is.

    But it would be a good idea to handle WebException.
    In WebException.Response.GetResponseStream() you should have either a HTTP/HTML error page or a soapfault.

    Asynch request

    // starts asynch retrieval of response stream…

    var result = request.BeginGetResponse(…)

    // setting a timeout callback method, BeginGetResponse doesn´t timeout…
    ThreadPool.RegisterWaitForSingleObject(result.AsyncWaitHandle, …)

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

Sidebar

Related Questions

Is there any way to get the local end point of a connected Silverlight
There Currently is a local debate as to which code is more readability We
Is there a way to use my SOAP web service(spring-ws, java) as a XML
i have local WSDL file. i tried to create JAX-WS Web service client which
I am wondering if there is local version control/snapshots for emacs independent of VC?
There are a few questions about configuring Apache for local development, such as this
Is there a way to run a local mpi job locally on os X
Is there any way to determine the local culture of a PC (such as
Is there a clean and OS independent way to determine the local machine's IP
Is there are way to progammatically determine the root directory's local path of the

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.