title: Sending SOAP Request to WebService error 500
body: <p>I got this exception when is send my SOAP request to my Web Service "The remote server returned an error: (500) Internal Server Error.". The WebService has 2 parameters (int a , int b). If i remove those two parameters, then i won't get any exception.</p>
  
  <p>This i my first experience with SOAP+WS. What do i do wrong?
  Thanks for taking your time.</p>
  
  <p>Edit:
  My college just found the error in my code. I was sending the  with an invalid header.</p>
  
  <p>Here is the missing header part:</p>
  
  <pre><code>request.Headers.Add("SOAPAction", "http://tempuri.org/Add");
  </code></pre>
  
  <p>Also, the url I'm using was incorrect.
  Wrong:</p>
  
  <pre><code>http://localhost:62830/Service1.asmx/Add
  </code></pre>
  
  <p>Correct:</p>
  
  <pre><code>http://localhost:62830/Service1.asmx
  </code></pre>
  
  <p>Here are my code
  Client that send SOAP to WebService</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
      {
  
          var url = UrlTextBox.Text;
          var xml_file_path = FileTextBox.Text;
  
          XmlDocument xml_doc = new XmlDocument();
          xml_doc.Load(xml_file_path);
  
          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
  
          request.Method = "POST";
          request.ContentType = "text/xml";
          request.Accept = "text/xml";
          request.Timeout = 30 * 1000;
  
          Stream request_stream = request.GetRequestStream();
          xml_doc.Save(request_stream);
          request_stream.Close();
  
          HttpWebResponse response = (HttpWebResponse)request.GetResponse();
          Stream r_stream = response.GetResponseStream();
  
          StreamReader response_stream = new StreamReader(r_stream, System.Text.Encoding.Default);
          string sOutput = response_stream.ReadToEnd();
  
          ResultTextBox.Text = sOutput;
  
      }
  </code></pre>
  
  <p>Here the XML file</p>
  
  <pre><code>        &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
        &lt;soap12:Body&gt;
          &lt;add xmlns="http://tempuri.org/" &gt;
          &lt;a&gt;5&lt;/a&gt;
          &lt;b&gt;10&lt;/b&gt;
          &lt;/add&gt;
        &lt;/soap12:Body&gt;
      &lt;/soap12:Envelope&gt;
  </code></pre>
  
  <p>And here the code in WebService</p>
  
  <pre><code>    [WebService(Namespace = "http://tempuri.org/")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [System.ComponentModel.ToolboxItem(false)]
  public class Service1 : System.Web.Services.WebService
  {
  
      [WebMethod]
      public int Add(int a, int b)
      {
          return a + b;
      }
  }
  </code></pre>