title: Calling web method in c# without web reference
body: <p>What is my mistake.
  I am trying to call asmx web method without web refernce, but i have an error on line:   </p>
  
  <pre><code>var result = client.UploadData(WebServiceUrl, data);
  </code></pre>
  
  <blockquote>
    <p>An unhandled exception of type 'System.Net.WebException' occurred in System.dll<br>
    Additional information: The remote server returned an error: (500) Internal Server Error. </p>
  </blockquote>
  
  <pre><code> class CallWebMethod
  {
      public string CallRemoteWebService()
      {
          string ResponseText = "";
  
          string WebServiceUrl = "http://192.168.1.3/META/services/ws.asmx"; 
          string WebMethodName = "FillXmlData"; 
  
          using (WebClient client = new WebClient())
          {
              client.Headers.Add("Content-Type", "text/xml; charset=utf-8");
                          var payload = string.Format(@"&lt;?xml version=""1.0"" encoding=""utf-8""?&gt;
           &lt;soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""&gt;
            &lt;soap:Body&gt;
              &lt;{0} xmlns=""http://www.curs.kz/gdmx/services/"" /&gt;
            &lt;/soap:Body&gt;
           &lt;/soap:Envelope&gt;", WebMethodName);
  
              var data = Encoding.UTF8.GetBytes(payload);
              var result = client.UploadData(WebServiceUrl, data);
  
              ResponseText = Encoding.Default.GetString(result);
  
          }
          return ResponseText;
      }
  }
  </code></pre>