title: How to write client side for soap in c#
body: <p>I have a project file which I have tested using SOAP UI. </p>
  
  <p><a href="https://i.stack.imgur.com/KGLsA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KGLsA.png" alt="enter image description here"></a></p>
  
  <p>Now I wanted to write it's client side so by viewing this <a href="https://stackoverflow.com/a/4791932/8919244">solution</a> I have tried to do things work. But I am having a problem. </p>
  
  <p>In the solution, <code>URL</code> and <code>action</code> are mentioned. I have a <code>URL</code> but I am not sure what is my <code>action URL</code>. So I put both of the same. </p>
  
  <pre><code>var _url = "http://111.111.111.1:111/HES/services/DoCommandRequest";
          var _action = "http://111.111.111.1:111/HES/services/DoCommandRequest";
  
   XmlDocument soapEnvelopeXml = CreateSoapEnvelope();
          HttpWebRequest webRequest = CreateWebRequest(_url, _action);
          InsertSoapEnvelopeIntoWebRequest(soapEnvelopeXml, webRequest);
  
          // begin async call to web request.
          IAsyncResult asyncResult = webRequest.BeginGetResponse(null, null);
  
          // suspend this thread until call is complete. You might want to
          // do something usefull here like update your UI.
          asyncResult.AsyncWaitHandle.WaitOne();
  
          // get the response from the completed web request.
          string soapResult;
          using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))
          {
              using (StreamReader rd = new StreamReader(webResponse.GetResponseStream()))
              {
                  soapResult = rd.ReadToEnd();
              }
              Console.Write(soapResult);
          }
  </code></pre>
  
  <p>After running my code I am getting an exception at <code>using (WebResponse webResponse = webRequest.EndGetResponse(asyncResult))</code> which says </p>
  
  <blockquote>
    <p>System.Net.WebException
    {"The remote server returned an error: (500) Internal Server Error."}</p>
  </blockquote>
  
  <p>I believe that there is some problem with my <code>action</code>, but I am not sure. </p>
  
  <p>Any help would be highly appreciated. </p>