title: loading multiple beans in spring boot using soap web service
body: <p>I  am trying to write soap webservice using spring boot.I have 2 xsd's. REL-6-MM7-1-4.xsd which is dependent on SoapEnvelope.xsd. </p>
  
  <p>Can anyone help me in resolving it.</p>
  
  <pre><code>import org.springframework.boot.web.servlet.ServletRegistrationBean;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.core.io.ClassPathResource;
  import org.springframework.ws.config.annotation.EnableWs;
  import org.springframework.ws.config.annotation.WsConfigurerAdapter;
  import org.springframework.ws.transport.http.MessageDispatcherServlet;
  import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
  import org.springframework.xml.validation.XmlValidator;
  import org.springframework.xml.xsd.SimpleXsdSchema;
  import org.springframework.xml.xsd.XsdSchema;
  import org.springframework.xml.xsd.XsdSchemaCollection;
  
  
  @EnableWs
  @Configuration
  public class WebServiceConfig extends WsConfigurerAdapter {
      @Bean
      public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
          MessageDispatcherServlet servlet = new MessageDispatcherServlet();
          servlet.setApplicationContext(applicationContext);
          servlet.setTransformWsdlLocations(true);
          return new ServletRegistrationBean(servlet, "/ws/*");
      }
  
      @Bean(name = "REL-6-MM7-1-4")
      public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchemaCollection xsdSchemaCollection) {
          DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
          wsdl11Definition.setPortTypeName("MMSPort");
          wsdl11Definition.setLocationUri("/ws");
          wsdl11Definition.setTargetNamespace("http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-6-MM7-1-4");
          wsdl11Definition.setSchemaCollection(xsdSchemaCollection);
          return wsdl11Definition;
      }
  
      @Bean
      public XsdSchemaCollection getXsdCollection() {
          return new XsdSchemaCollection() {
  
              public XsdSchema[] getXsdSchemas() {
                  return new XsdSchema[]{new SimpleXsdSchema(new ClassPathResource("REL-6-MM7-1-4.xsd")), new SimpleXsdSchema(new ClassPathResource("SoapEnvelope.xsd"))};
              }
  
              public XmlValidator createValidator() {
                  throw new UnsupportedOperationException();
              }
          };
      }
  </code></pre>
  
  <p>I have tried to expose 2 beans but when i startup the application i get following error.</p>
  
  <p>Error creating bean with name 'REL-6-MM7-1-4' defined in class path resource [hello/WebServiceConfig.class]: Invocation of init method failed; nested exception is java.lang.NullPointerException</p>