Spring Boot SOAP Web服务的EndpointNotFound异常

时间:2014-10-21 23:49:22

标签: java web-services soap spring-boot spring-ws

我正在使用spring boot WS尝试使用SOAP Web服务。我正在创建一个maven war项目并在tomcat中部署。 wsdl文件生成成功,但是当我从SOAPUI尝试时,我得到以下错误: -

o.s.ws.server.EndpointNotFound           : No endpoint mapping found for [SaajSoapMessage {http://spring.io/guides/gs-producing-web-service}sampleRequest]

请在下面找到详细信息: -

 @EnableWs
@Configuration
@EnableAutoConfiguration
public class WebServiceConfig extends WsConfigurerAdapter {
    @Bean
    public ServletRegistrationBean dispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);
        servlet.setTransformWsdlLocations(true);
        return new ServletRegistrationBean(servlet, "/ws/*");
    }

    @Bean(name = "countries")
    public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
        DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
        wsdl11Definition.setPortTypeName("CountriesPort");
        wsdl11Definition.setLocationUri("/ws");
        wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service");
        wsdl11Definition.setSchema(countriesSchema);
        return wsdl11Definition;
    }

    @Bean
    public XsdSchema countriesSchema() {
        return new SimpleXsdSchema(new ClassPathResource("countries.xsd"));
    }
}

端点类: -

@Endpoint
public class ServiceImpl {

    private static final String NAMESPACE_URI = "http://spring.io/guides/gs-producing-web-service";

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "sampleRequest")
    @ResponsePayload
    public JAXBElement<SampleResponse> sampleMethod(
            @RequestPayload JAXBElement<SampleRequest> sampleRequest) {

            System.out.println("hi");
            return null;
    }
}

来自pom.xml的依赖

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.1.8.RELEASE</version>
    </parent>

    <dependencies>      

        <dependency>
            <groupId>org.jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>2.0.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-ws</artifactId>
            <version>1.2.0.M2</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.6.3</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

Xsd: -

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://spring.io/guides/gs-producing-web-service"
           targetNamespace="http://spring.io/guides/gs-producing-web-service" elementFormDefault="qualified">

    <xs:element name="sampleResponse">
        <xs:complexType>
            <xs:sequence>
                <xs:element type="xs:string" name="auditReference" />
                <xs:element type="xs:string" name="responseCode" />
                <xs:element type="xs:string" name="responseMessage" />

            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="sampleRequest">
        <xs:complexType>
            <xs:sequence>
                <xs:element type="xs:string" name="apikey">
                    <xs:annotation>
                        <xs:documentation>Optional:</xs:documentation>
                    </xs:annotation>
                </xs:element>

            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

完整的错误日志: -

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.1.8.RELEASE)

2014-10-22 00:36:11.035  INFO 1016 --- [gine[Catalina]]] o.s.boot.SpringApplication               : Starting application on LASST262540 with PID 1016 (D:\O2\workspace\21Oct\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\gs-producing-web-service\WEB-INF\lib\spring-boot-1.1.8.RELEASE.jar started by MVenugo1 in D:\sw\eclipse-jee-luna-R-win32\eclipse)
2014-10-22 00:36:11.082  INFO 1016 --- [gine[Catalina]]] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3a9aaf: startup date [Wed Oct 22 00:36:11 BST 2014]; root of context hierarchy
2014-10-22 00:36:11.884  INFO 1016 --- [gine[Catalina]]] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'org.springframework.boot.autoconfigure.AutoConfigurationPackages': replacing [Generic bean: class [org.springframework.boot.autoconfigure.AutoConfigurationPackages$BasePackages]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Generic bean: class [org.springframework.boot.autoconfigure.AutoConfigurationPackages$BasePackages]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
2014-10-22 00:36:11.998  INFO 1016 --- [gine[Catalina]]] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2014-10-22 00:36:13.146  INFO 1016 --- [gine[Catalina]]] trationDelegate$BeanPostProcessorChecker : Bean 'webServiceConfig' of type [class hello.WebServiceConfig$$EnhancerBySpringCGLIB$$2a27dca8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-10-22 00:36:13.166  INFO 1016 --- [gine[Catalina]]] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [class org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$ae9cf03] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-10-22 00:36:13.254  INFO 1016 --- [gine[Catalina]]] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2014-10-22 00:36:13.301  INFO 1016 --- [gine[Catalina]]] .a.c.c.C.[.[.[/gs-producing-web-service] : Initializing Spring embedded WebApplicationContext
2014-10-22 00:36:13.301  INFO 1016 --- [gine[Catalina]]] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2219 ms
2014-10-22 00:36:14.759  INFO 1016 --- [gine[Catalina]]] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'messageDispatcherServlet' to [/ws/*]
2014-10-22 00:36:14.760  INFO 1016 --- [gine[Catalina]]] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'errorPageFilter' to: [/*]
2014-10-22 00:36:14.761  INFO 1016 --- [gine[Catalina]]] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'metricFilter' to: [/*]
2014-10-22 00:36:14.761  INFO 1016 --- [gine[Catalina]]] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-10-22 00:36:14.761  INFO 1016 --- [gine[Catalina]]] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'applicationContextIdFilter' to: [/*]
2014-10-22 00:36:14.762  INFO 1016 --- [gine[Catalina]]] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2014-10-22 00:36:15.134  INFO 1016 --- [gine[Catalina]]] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-10-22 00:36:15.252  INFO 1016 --- [gine[Catalina]]] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2014-10-22 00:36:15.253  INFO 1016 --- [gine[Catalina]]] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2014-10-22 00:36:15.275  INFO 1016 --- [gine[Catalina]]] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-10-22 00:36:15.276  INFO 1016 --- [gine[Catalina]]] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-10-22 00:36:15.808  INFO 1016 --- [gine[Catalina]]] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2014-10-22 00:36:15.860  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Registering beans for JMX exposure on startup
2014-10-22 00:36:15.956  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/dump],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.956  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/beans],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.957  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/info],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.957  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics/{name:.*}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2014-10-22 00:36:15.958  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.958  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/autoconfig],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.959  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/health],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke()
2014-10-22 00:36:15.959  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/configprops],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.960  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/mappings],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.960  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/trace],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.961  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env/{name:.*}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2014-10-22 00:36:15.961  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2014-10-22 00:36:15.976  INFO 1016 --- [gine[Catalina]]] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2014-10-22 00:36:15.979  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'requestMappingEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=requestMappingEndpoint]
2014-10-22 00:36:16.007  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'environmentEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=environmentEndpoint]
2014-10-22 00:36:16.013  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'healthEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=healthEndpoint]
2014-10-22 00:36:16.020  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'beansEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=beansEndpoint]
2014-10-22 00:36:16.028  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'infoEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=infoEndpoint]
2014-10-22 00:36:16.033  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'metricsEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=metricsEndpoint]
2014-10-22 00:36:16.042  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'traceEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=traceEndpoint]
2014-10-22 00:36:16.046  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'dumpEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=dumpEndpoint]
2014-10-22 00:36:16.054  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'autoConfigurationAuditEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=autoConfigurationAuditEndpoint]
2014-10-22 00:36:16.059  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'shutdownEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=shutdownEndpoint]
2014-10-22 00:36:16.068  INFO 1016 --- [gine[Catalina]]] o.s.b.a.e.jmx.EndpointMBeanExporter      : Located managed bean 'configurationPropertiesReportEndpoint': registering with JMX server as MBean [org.springframework.boot:type=Endpoint,name=configurationPropertiesReportEndpoint]
2014-10-22 00:36:16.086  INFO 1016 --- [gine[Catalina]]] o.s.boot.SpringApplication               : Started application in 5.583 seconds (JVM running for 276.935)
2014-10-22 00:36:16.095  INFO 1016 --- [gine[Catalina]]] o.apache.catalina.core.StandardContext   : Reloading Context with name [/gs-producing-web-service] is completed
2014-10-22 00:36:17.135  INFO 1016 --- [apr-8080-exec-2] .a.c.c.C.[.[.[/gs-producing-web-service] : Initializing Spring FrameworkServlet 'messageDispatcherServlet'
2014-10-22 00:36:17.144  INFO 1016 --- [apr-8080-exec-2] o.s.w.t.http.MessageDispatcherServlet    : FrameworkServlet 'messageDispatcherServlet': initialization started
2014-10-22 00:36:17.167  INFO 1016 --- [apr-8080-exec-2] o.s.ws.soap.saaj.SaajSoapMessageFactory  : Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
2014-10-22 00:36:17.190  INFO 1016 --- [apr-8080-exec-2] o.s.w.t.http.MessageDispatcherServlet    : FrameworkServlet 'messageDispatcherServlet': initialization completed in 45 ms
2014-10-22 00:36:17.301  WARN 1016 --- [apr-8080-exec-2] o.s.ws.server.EndpointNotFound           : No endpoint mapping found for [SaajSoapMessage {http://spring.io/guides/gs-producing-web-service}sampleRequest]

1 个答案:

答案 0 :(得分:2)

最后我有解决方案。 将组件结构添加到组件scan.It为空,如下所示(前面)。

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}