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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:42:46+00:00 2026-05-22T00:42:46+00:00

Recently I’ve been experiencing a nightmare with .NET (C#) and SOAP Transmissions. I’ve got

  • 0

Recently I’ve been experiencing a nightmare with .NET (C#) and SOAP Transmissions.
I’ve got to consume a webservice (which was supposed to be an easy task) but it become terrible and nothing seem to works.

HttpWebRequest webRequest = (HttpWebRequest)System.Net.WebRequest.Create("http://api.myapi.com/apis/services/theapi");

webRequest.AllowAutoRedirect = true;
webRequest.Timeout = 1000 * 30;
webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
webRequest.PreAuthenticate = true;
webRequest.Method = "POST";
webRequest.Headers.Add("SOAPAction: \"\"");
webRequest.Accept = "text/xml";

WebResponse webResponse = null;

try
{
    webResponse = webRequest.GetResponse();

    Stream Stream = webRequest.GetRequestStream();
    string SoapEnvelope = "<soap:Envelope>...SOAP CODE ...</soap:Envelope>";
    StreamReader streamReader = new StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.UTF8);

    XmlDocument SoapEnvelopeXML = new XmlDocument();
    SoapEnvelopeXML.LoadXml(SoapEnvelope);

    SoapEnvelopeXML.Save(Stream);

    string result = streamReader.ReadToEnd();
    return result;
}

When I try to sniff the packages by using Wireshark, that’s what I get:

---- CLIENT INPUT ------
POST /apis/services/theapi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
SOAPAction: ""
Accept: text/xml
Host: api.myapi.com

Connection: Keep-Alive

---- SERVER ANSWER ------

HTTP/1.1 500 Internal Server Error
Date: Sat, 14 May 2011 15:35:32 GMT
X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5
Content-Type: text/xml;charset=ISO-8859-1
Content-Length: 225
Connection: close
X-Pad: avoid browser bug

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Error reading XMLStreamReader.</faultstring></soap:Fault></soap:Body></soap:Envelope>

As expected, since I haven’t posted a Soap Request (no XML in the request), I receive a SOAP Fault and ERROR 500.

Any ideas?

I’ve got to somehow do this manually. I’ve tried to use even TCPClient (to deal with it in a lower level), but all my attempts were frustrated.

  • 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-22T00:42:47+00:00Added an answer on May 22, 2026 at 12:42 am

    You should use the VS Add Service Reference wizard to load the service into your project. The Add Service Reference generates classes to work with the api automatically at a much higher level, from the url of the service API endpoint. It will look something like this:

    MyApiClient client = new MyApiClient();
    MyApiResult result;
    
    try {
        client.Open();
        result = client.CallMethod(param1, param2, ...);
        client.Close();
    } catch (Exception ex) {
        // do something with FaultException or API error
    }
    
    // do something with the result returned, if needed
    

    If you’ve done it correct, you shouldn’t have to deal with HttpWebRequest, explicit URL’s, or hand-typing out any SOAP XML at all!!

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

Sidebar

Related Questions

Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, I've been dealing with an error with accessing MAPI via the .NET framework
Recently I was asked to develop an app, which basically is going to use
Recently, I was writing a class in which I discovered that I could reduce
Recently launched a Magento store which features an image slider on the homepage. Works
Recently I have been dealing with windows LogonUser API. The LogonUser api returns different
Recently two users of our software from the same company started experiencing random closures
Recently I've been doing quite the project mostly working with the DateTime class. Now,..
Recently I've been dealing with texts with mixed languages, including Chinese, English, and even
Recently I've been thinking about how to transform a complex polygon into a non-complex

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.