title: WF4 - How to consume external web service?
body: <p>I'm having a really hard time trying to find a resource or online tutorial that explicitly walks you through setting up a WF4 workflow activity that can call out to an external web service.  All the videos and online samples I've come across simply demonstrate how to consume a web service that's part of your Visual Studio solution, but my situation entails calling out to a web service on a non-Microsoft server.</p>
  
  <p>I have a service reference added to my VS2010 workflow console project for the web service in question, and it's pointing to the WSDL of the external web service.  So far, so good (I think).  I have a very basic workflow sequence, using a <strong>SendAndReceiveReply</strong> workflow control to communicate with the external server, and I believe I have the <strong>Send</strong> piece configured correctly.  The <strong>ReceiveReplyForSend</strong> is giving me trouble, however, and I'm not sure if I have its <strong>Content</strong> options set up the right way.  I'm invoking an operation called <strong>FileCheck</strong>, which at the moment for testing purposes always returns a value of 1 like this:</p>
  
  <pre><code>&lt;SOAP-ENV:Envelope&gt;
      &lt;SOAP-ENV:Body&gt;
          &lt;FileCheckResponse&gt;
              &lt;FileCheckResult&gt;1&lt;/FileCheckResult&gt;
          &lt;/FileCheckResponse&gt;
      &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>If I try to run this, however, I get the error "Badly formed SOAP message." For what it's worth, my ReceiveReplyForSend has a single parameter set up called <strong>FileCheckResult</strong>, though I don't know if that's the correct way to get the above value.</p>
  
  <p>I can put a breakpoint at either activity, but I have no idea how to see what the SOAP call looks like at that point.  Can someone either give me some workflow Send/Reply debugging tips or point me in the direction of an excellent step-by-step tutorial of how to consume an external web service in WF4?</p>
  
  <p><strong>Update on Feb. 2, 2011:</strong> Thanks to Maurice's suggestion, I see exactly what is failing now.  The web service call in my workflow is failing because Visual Studio is generating a reference to the wrong namespace in my workflow Send call.  Here is the single bit of XML that is wrong in the SOAP message - I'll leave off the rest of the SOAP envelope for succinctness:</p>
  
  <pre><code>&lt;FileCheck xmlns="http://tempuri.org/"&gt;
  </code></pre>
  
  <p>This is what the WCF Test Client generates, which gets a successful message in return:</p>
  
  <pre><code>&lt;FileCheck xmlns="http://someserver.org/test/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;
  </code></pre>
  
  <p>This is probably a really newbie question, but is there a setting somewhere that I'm overlooking that adjusts the <strong>xmlns</strong> value?  I tried searching for "tempuri" in my project, but it's nowhere to be found, so I bet I'm overlooking a default setting somewhere.</p>
  
  <p><strong>Update on February 8, 2011:</strong> Maurice's latest tip did the trick!  I needed to add the proper namespace to the <strong>ServiceContractName</strong> property for my <strong>Send</strong> workflow activity.</p>