title: Consuming a SOAP web service error (No marshaller registered. Check configuration of WebServiceTemplate)
body: <p>I've followed the Getting Started - Consuming a SOAP web service (<a href="https://spring.io/guides/gs/consuming-web-service/" rel="noreferrer">https://spring.io/guides/gs/consuming-web-service/</a>) to consume a specific web service and everything works well:</p>
  
  <p>I've made the configuration class:</p>
  
  <pre><code>@Configuration
  public class PMConfiguration {
      @Bean
      public Jaxb2Marshaller marshaller() {
          Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
          // this package must match the package in the &lt;generatePackage&gt; specified in
          // pom.xml
          marshaller.setContextPath("com.inteligenciaweb.wsdl");
          return marshaller;
      }
  
      @Bean
      public ProcuraPMPorREClient procuraPMPorREClient(Jaxb2Marshaller marshaller) {
          ProcuraPMPorREClient client = new ProcuraPMPorREClient();
          client.setDefaultUri("http://tempuri.org/procuraPMPorRE");
          client.setMarshaller(marshaller);
          client.setUnmarshaller(marshaller);
          return client;
      } 
  </code></pre>
  
  <p>}</p>
  
  <p>Client:</p>
  
  <pre><code>public class ProcuraPMPorREClient extends WebServiceGatewaySupport {
  
      private static final Logger log = LoggerFactory.getLogger(ProcuraPMPorRE.class);
  
  
      public ProcuraPMPorREResponse getPMPorRE(Integer RE) {
  
          ProcuraPMPorRE request = new ProcuraPMPorRE();
          request.setPMRENum(RE);
  
          log.info("Requesting PM for " + RE);
  
          ProcuraPMPorREResponse response = (ProcuraPMPorREResponse) getWebServiceTemplate()
                  .marshalSendAndReceive("http://webservices.externo.policiamilitar.sp.gov.br:8071/router/wsscpm/basic",
                          request,
                          new SoapActionCallback("http://tempuri.org/procuraPMPorRE"));
  
          return response;
      }
  
  }
  </code></pre>
  
  <p>At the class Application:</p>
  
  <pre><code>@SpringBootApplication
  public class InteligenciawebApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(InteligenciawebApplication.class, args);
      }
  
      @Bean
      CommandLineRunner lookup(ProcuraPMPorREClient pm) {
          return args -&gt; {
              Integer re = 123456;        
              ProcuraPMPorREResponse response = pm.getPMPorRE(re); 
              System.err.println(response.getProcuraPMPorREResult().getNomeBancoPM());
          };
      }
  }
  </code></pre>
  
  <p>When I start a application, the weservice calling works fine, so I can see the result at the console. I've tried to use the same logic to call this web service in other class, but isn't working. For instance, I've made a test at the Controller Class:</p>
  
  <pre><code>@RequestMapping(value = "/soap", method = RequestMethod.GET)
  public String testeSoap() {
      ProcuraPMPorREClient pm = new ProcuraPMPorREClient();
      ProcuraPMPorREResponse response = pm.getPMPorRE(123456); 
      System.out.println(response.getProcuraPMPorREResult().getNomePM());
    return null;
  }
  </code></pre>
  
  <p>In this case, the webservice doesn't work and the system show this error message: java.lang.IllegalStateException: No marshaller registered. Check configuration of WebServiceTemplate. I don't know why, but the webservice works in a specific place and doesn't work in the other. If someone knows what happen, I apreciate! Thanks!</p>