title: How to consume a webservice in Excel 2013
body: <p>I have a web service that I can call using Microsoft's WCFTestClient.exe.  However, when I try to create a macro in Excel 2013 to call the web service, it doesn't work.</p>
  
  <p>It doesn't error, but it doesn't actually run the method (RunScript) on the web server either.  </p>
  
  <p>Here is my code:</p>
  
  <pre><code>Private Sub web()
  
  
  Dim sURL As String
  Dim sEnv As String
  Dim objHTTP As Object
  Set objHTTP = CreateObject("MSXML2.XMLHTTP.6.0")
   sURL = "http://testserver:9001/TestService"
  
   On Error GoTo ErrorLabel
  
  
   sEnv = sEnv &amp; "&lt;s:Envelope xmlns:a=""http://www.w3.org/2005/08/addressing"" xmlns:s=""http://www.w3.org/2003/05/soap-envelope"" &gt; "
   sEnv = sEnv &amp; " &lt;s:Header&gt;"
   sEnv = sEnv &amp; "  &lt;a:Action s:mustUnderstand=""1""&gt;http://tempuri.org/TestService/RunScript&lt;/a:Action&gt;"
   sEnv = sEnv &amp; "  &lt;a:MessageID&gt;urn:uuid:9405af92-1f5b-4ead-87&lt;/a:MessageID&gt; &lt;a:ReplyTo&gt;"
   sEnv = sEnv &amp; "        &lt;a:Address&gt;http://www.w3.org/2005/08/addressing/anonymous&lt;/a:Address&gt;"
   sEnv = sEnv &amp; "    &lt;/a:ReplyTo&gt;"
   sEnv = sEnv &amp; " &lt;/s:Header&gt;"
   sEnv = sEnv &amp; "  &lt;s:Body&gt;"
   sEnv = sEnv &amp; "    &lt;RunScript xmlns=""http://tempuri.org/""/&gt; "
   sEnv = sEnv &amp; "  &lt;/s:Body&gt;"
   sEnv = sEnv &amp; "&lt;/s:Envelope&gt;"
  
   With objHTTP
      .Open "GET", sURL, False
      .setRequestHeader "Content-Type", "text/xml"
      .send sEnv
  End With
  
   Set objHTTP = Nothing
  ExitLabel:
     'Clean-up code, if any, goes here
     Exit Sub
  
  ErrorLabel:
      'Error-handling code goes here
      Resume ExitLabel
  
  End Sub
  </code></pre>
  
  <p>I know the webservice works, because I've created other clients that have successfully consumed the webservice.  What am I doing wrong with this Excel 2013 macro?</p>
  
  <p>**EDIT -- the above was using wsHTTPBinding, I switched it to use basicHTTPBinding:</p>
  
  <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;s:Header&gt;
      &lt;Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://tempuri.org/TestService/RunScript&lt;/Action&gt;
    &lt;/s:Header&gt;
    &lt;s:Body&gt;
      &lt;RunScript xmlns="http://tempuri.org/" /&gt;
    &lt;/s:Body&gt;
  &lt;/s:Envelope&gt;
  </code></pre>
  
  <p>I ran it in fiddler but eventually get a 504 - Gateway timout.  Running the WCFClient and adding the service works as well as writing a small console app to consume it(by adding a web reference).  </p>
  
  <p>The soap xml I am using is the exact one from the WCFClient tool.</p>
  
  <p>Thanks in advance!</p>