title: Visual Studio WSDL create async/await SOAP webservice
body: <p>I've got a SOAP webservice in my C# winforms application, but I'm trying to get WSDL.exe to generate with Task-Based async/await methods.</p>
  
  <p>I've read up on the documentation <a href="https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/7h3ystb6(v=vs.100)" rel="nofollow noreferrer">here</a> and tried adding the following XML file into the <code>par</code> switch but its still not giving me the awaitable Task based methods for calling the webservice methods asynchronously. </p>
  
  <pre><code>// BEGIN WSDLPARAMETERS.XML
  
  &lt;wsdlParameters  xmlns="http://microsoft.com/webReference/"&gt;
    &lt;webReferenceOptions&gt;
      &lt;verbose&gt;false&lt;/verbose&gt;
      &lt;codeGenerationOptions&gt;properties newAsync enableDataBinding&lt;/codeGenerationOptions&gt;
    &lt;/webReferenceOptions&gt;
  &lt;/wsdlParameters&gt;
  
  // END WSDLPARAMETERS.XML
  
  C:\Program Files (x86)\Microsoft Visual Studio\2017\Community&gt;wsdl.exe  "http://********/interchangeservices.asmx" /out:"****\WebServices.cs" /l:CS  /n:"AdelaideInterchangeAutomation" /par:"*****\wsdlparameters.xml"
  </code></pre>
  
  <p>this returns methods like this</p>
  
  <pre><code>    /// &lt;remarks/&gt;
  
      public AwaitingUpload CheckHistoryNotUploaded() {
          object[] results = this.Invoke("CheckHistoryNotUploaded", new object[0]);
          return ((AwaitingUpload)(results[0]));
      }
  
      /// &lt;remarks/&gt;
      public void CheckHistoryNotUploadedAsync() {
          this.CheckHistoryNotUploadedAsync(null);
      }
  
      /// &lt;remarks/&gt;
      public void CheckHistoryNotUploadedAsync(object userState) {
          if ((this.CheckHistoryNotUploadedOperationCompleted == null)) {
              this.CheckHistoryNotUploadedOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCheckHistoryNotUploadedOperationCompleted);
          }
          this.InvokeAsync("CheckHistoryNotUploaded", new object[0], this.CheckHistoryNotUploadedOperationCompleted, userState);
      }
  
      private void OnCheckHistoryNotUploadedOperationCompleted(object arg) {
          if ((this.CheckHistoryNotUploadedCompleted != null)) {
              System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
              this.CheckHistoryNotUploadedCompleted(this, new CheckHistoryNotUploadedCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
          }
      }
  </code></pre>
  
  <p>but ideally I would like it to return Task-Based async methods so i can call them with the <code>await</code> keyword.</p>
  
  <pre><code>    public AwaitingUpload CheckHistoryNotUploaded() {
          object[] results = this.Invoke("CheckHistoryNotUploaded", new object[0]);
          return ((AwaitingUpload)(results[0]));
      }
  
      /// &lt;remarks/&gt;
      public async Task&lt;AwaitingUpload&gt; CheckHistoryNotUploadedAsync() {
          await .....
      }
  </code></pre>