title: How do I simply call an asyc WCF service method using Rx
body: <p>I have been struggling to figure out how to use Rx. Most of the examples are out of date, reference Begin/End or are long and complex.</p>
  
  <p>I have a simple WCF service method that takes an int and returns a JobMaster object.</p>
  
  <p>Here is how I call it at the moment:</p>
  
  <pre><code>    public static void GetJob(int jobId)
      {
          KernServiceClient.GetJobCompleted += GetJobCompleted;
          KernServiceClient.GetJobAsync(jobId);
      }
  
      private static void GetJobCompleted(object sender, GetJobCompletedEventArgs e)
      {
          // JobMaster available in e.Result
      }
  </code></pre>
  
  <p>How do I change this to use Rx?</p>
  
  <p>EDIT</p>
  
  <p>Thanks to Paul's help I have got most of the way there. This is what it looks like now. Only problem is the Subscribe never fires. Any ideas?</p>
  
  <pre><code>    public static JobMaster GetJob(int jobId)
      {
          JobMaster retval = null;
  
          IKernService kernServiceInterface = KernServiceClient;
  
          var getJobFunc = Observable.FromAsyncPattern&lt;int, Server.KernMobileWcfService.JobMaster&gt;(
              kernServiceInterface.BeginGetJob, kernServiceInterface.EndGetJob);
  
          var result = getJobFunc(jobId);
  
          result
              .Subscribe
              (
                  onNext: x =&gt; retval = ConvertJobMaster(x),
                  onError: ex =&gt; ShowError(ex.Message)
              );
  
          return retval;
      }
  </code></pre>