title: SOAP client in Delphi "The handle is in the wrong state for the requested operation"
body: <p>I have built the worlds dumbest and most simple SOAP server, in about 3 clicks, in visual studio. The exact steps in visual studio 2010: First create a new project as a web application, Then add a new item of type web service. (See accepted answer <a href="https://stackoverflow.com/questions/8188997/how-do-i-create-a-simple-soap-server-using-c-sharp-in-visual-studio-2010/8189138#8189138">here</a> for picture.) That soap server service Service1 has a simple method GetData:</p>
  
  <p>A snippet from clientService1.pas, created using WSDL importer...</p>
  
  <pre><code>  IService1 = interface(IInvokable)
    ['{967498E8-4F67-AAA5-A38F-F74D8C7E346A}']
      function  GetData(const value: Integer): string; stdcall;
      function  GetDataUsingDataContract(const composite: CompositeType2): CompositeType2; stdcall;
    end;
  </code></pre>
  
  <p>When I try to run this method, like this:</p>
  
  <pre><code>procedure TForm3.Button1Click(Sender: TObject);
  var
   rio : THTTPRIO;
   sv:IService1;
   addr : string;
   data : string;
  begin
      //addr := '....'; // url from visual studio 2010 live debug instance.
      rio := THTTPRIO.Create(nil);
      sv := GetIService1( true, addr, rio );
      try
          data := sv.GetData(  0);
  
          Button1.Caption := data;
  
      finally
          sv := nil;
  
          rio.Free;
      end;
   end;
  </code></pre>
  
  <p>The error I get is this:</p>
  
  <pre><code>ESOAPHTTPException: 
   The handle is in the wrong state for the requested operation -    
   URL:http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary1/Service1/ -      
   SOAPAction:http://tempuri.org/IService1/GetData'.
  </code></pre>
  
  <p>The URL works fine when I paste the url above into a web browser, so the usual answer that the SOAP code in Delphi has the tendency to not notice an HTTP failure, does not seem likely. Rather it seems that I am either (a) experiencing breakage in WinInet (known to happen in some versions of windows), or (b) doing something wrong?</p>
  
  <p>It seems to me that anybody who has visual studio and delphi both installed, should be able to try to get the dummy starter Soap server in Visual Studio talking to the soap client in Delphi, without any effort at all. But I can not figure out the simplest things.</p>