title: Spring Batch - Call as webservice
body: <p>I have a Spring Batch job. I am new to Spring Batch and have always been called via the CommandLineJobRunner. </p>
  
  <p>This is what my call looks like:</p>
  
  <pre><code>org.springframework.batch.core.launch.support.CommandLineJobRunner spring-batch-myProject.xml SpringJobBean.MyProjectImportDataJob
  </code></pre>
  
  <p>Now I have to call my batch job from within a webservice (Spring MVC). In my endpoint this is the invoke call. I need to call the batch job in the if statement. How would I do this? I read about JobLauncher...but not sure how to tell it what to launch?</p>
  
  <pre><code>protected Object invokeInternal(Object aObj) throws Exception {
      RunDataProcessingImportRequest request = (RunDataProcessingImportRequest) aObj;
  
      RunDataProcessingImportResponse response = new RunDataProcessingImportResponse();
      if (request.getDataProcessingType().equals(PROJECT_TYPE)){
  
          response.setResultCd(1);
      } else {
          response.setResultCd(0);
          response.setErrorCode(1l);
          response.setErrorMessage("Incorrect process type");
      }
      return response;
  }
  </code></pre>