使用WSDL EndpointNotFound的Spring Boot项目

时间:2018-01-07 12:18:23

标签: spring spring-boot soap wsdl endpointnotfoundexception

大家!!!

我的这个项目基于http://javainuse.com/spring/springbootsoapwebservice,但我得到了EndpointNotFound。

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>TesteSOAPWSDL</groupId>

  <artifactId>TesteSOAPWSDL</artifactId>

  <version>1.0.0-SNAPSHOT</version>

  <name>Archetype - TesteSOAPWSDL</name>

  <url>http://maven.apache.org</url>

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <maven-jaxb2-plugin.version>0.13.2</maven-jaxb2-plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web-services</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>${maven-jaxb2-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>                    
                    <schemaIncludes>
                        <include>*.wsdl</include>
                    </schemaIncludes>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

WSDL

    <?xml version="1.0" encoding="ISO-8859-1"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://notificacao.service.vendasout.m4u.com"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    targetNamespace="http://notificacao.service.vendasout.m4u.com">
    <types>
        <xs:schema xmlns:tns="http://notificacao.service.vendasout.m4u.com"
            xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://notificacao.service.vendasout.m4u.com"
            version="1.0">
            <xs:element name="VendasEfetivasRequest" type="tns:vendasEfetivasRequisicao" />
            <xs:element name="avisoVendaTO" type="tns:avisoVendaTO" />
            <xs:element name="listarVendasEfetivasPeriodo" type="tns:listarVendasEfetivasPeriodo" />
            <xs:element name="listarVendasEfetivasPeriodoResponse"
                type="tns:listarVendasEfetivasPeriodoResponse" />
            <xs:element name="vendasEfetivasResposta">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element minOccurs="0" name="resposta" type="xs:string" />
                        <xs:element maxOccurs="unbounded" minOccurs="0"
                            name="vendas_efetivas" type="tns:avisoVendaTO" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:complexType name="listarVendasEfetivasPeriodo">
                <xs:sequence>
                    <xs:element minOccurs="0" name="request"
                        type="tns:vendasEfetivasRequisicao" />
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="vendasEfetivasRequisicao">
                <xs:sequence>
                    <xs:element name="usuario" type="xs:string" />
                    <xs:element name="senha" type="xs:string" />
                    <xs:element name="inicio" type="xs:string" />
                    <xs:element name="fim" type="xs:string" />
                    <xs:element name="marcador" type="xs:string" />
                    <xs:element name="limite" type="xs:string" />
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="listarVendasEfetivasPeriodoResponse">
                <xs:sequence>
                    <xs:element minOccurs="0" name="return">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element minOccurs="0" name="resposta" type="xs:string" />
                                <xs:element maxOccurs="unbounded" minOccurs="0"
                                    name="vendas_efetivas" type="tns:avisoVendaTO" />
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:complexType>
            <xs:complexType name="avisoVendaTO">
                <xs:sequence>
                    <xs:element minOccurs="0" name="data_notificacao" type="xs:dateTime" />
                    <xs:element minOccurs="0" name="data_efetiva" type="xs:string" />
                    <xs:element minOccurs="0" name="hora_efetiva" type="xs:string" />
                    <xs:element minOccurs="0" name="codigo_consultor" type="xs:string" />
                    <xs:element minOccurs="0" name="nome_consultor" type="xs:string" />
                    <xs:element minOccurs="0" name="codigo_distribuidor"
                        type="xs:string" />
                    <xs:element minOccurs="0" name="nome_distribuidor" type="xs:string" />
                    <xs:element minOccurs="0" name="iccid" type="xs:string" />
                    <xs:element minOccurs="0" name="status" type="xs:string" />
                    <xs:element minOccurs="0" name="canal" type="xs:string" />
                    <xs:element minOccurs="0" name="valor_recarga" type="xs:string" />
                    <xs:element minOccurs="0" name="protocolo" type="xs:string" />
                    <xs:element minOccurs="0" name="ddd" type="xs:string" />
                    <xs:element minOccurs="0" name="regional" type="xs:string" />
                    <xs:element minOccurs="0" name="tim_dicas" type="xs:string" />
                    <xs:element minOccurs="0" name="tipo_acao" type="xs:string" />
                    <xs:element minOccurs="0" name="tipo_chip" type="xs:string" />
                    <xs:element minOccurs="0" name="valor_chip" type="xs:string" />
                    <xs:element minOccurs="0" name="chip_supervisor" type="xs:string" />
                    <xs:element minOccurs="0" name="data_estoque" type="xs:string" />
                    <xs:element minOccurs="0" name="operadora" type="xs:string" />
                    <xs:element minOccurs="0" name="doacao" type="xs:string" />
                    <xs:element minOccurs="0" name="portabilidade" type="xs:string" />
                    <xs:element minOccurs="0" name="origem" type="xs:string" />
                    <xs:element minOccurs="0" name="perfil_atuacao" type="xs:string" />
                    <xs:element minOccurs="0" name="local_acao" type="xs:string" />
                    <xs:element minOccurs="0" name="pre_high" type="xs:string" />
                    <xs:element minOccurs="0" name="cpf_consultor" type="xs:string" />
                    <xs:element minOccurs="0" name="data_cadastro" type="xs:dateTime" />
                    <xs:element minOccurs="0" name="supervisor" type="xs:string" />
                    <xs:element minOccurs="0" name="tipo_plano" type="xs:string" />
                    <xs:element minOccurs="0" name="numero_tim" type="xs:string" />
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </types>

    <message name="VendasEfetivasTIM_listarVendasEfetivasPeriodoResponse">
        <part element="tns:listarVendasEfetivasPeriodoResponse" name="listarVendasEfetivasPeriodoResponse" />
    </message>

    <message name="VendasEfetivasTIM_listarVendasEfetivasPeriodo">
        <part element="tns:listarVendasEfetivasPeriodo" name="listarVendasEfetivasPeriodo" />
    </message>

    <portType name="VendasEfetivasTIM">
        <operation name="listarVendasEfetivasPeriodo"
            parameterOrder="listarVendasEfetivasPeriodo">
            <input message="tns:VendasEfetivasTIM_listarVendasEfetivasPeriodo" />
            <output message="tns:VendasEfetivasTIM_listarVendasEfetivasPeriodoResponse" />
        </operation>
    </portType>

    <binding name="VendasEfetivasTIMBinding" type="tns:VendasEfetivasTIM">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <operation name="listarVendasEfetivasPeriodo">
            <soap:operation soapAction="http://notificacao.service.vendasout.m4u.com" style="document" />
            <input>
                <soap:body parts="listarVendasEfetivasPeriodo" use="literal" />
            </input>
            <output>
                <soap:body parts="listarVendasEfetivasPeriodoResponse" use="literal" />
            </output>
        </operation>
    </binding>

    <service name="VendasEfetivasTIMService">
        <port binding="tns:VendasEfetivasTIMBinding" name="VendasEfetivasTIMPort">
            <soap:address
                location="http://tim-vendasout-core-prd-94:8080/core/vendasout/consultaws" />
        </port>
    </service>
</definitions>

应用:

package com.javainuse;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan(basePackages = {"com.javainuse"})
public class SpringBootHelloWorldApplication {

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

配置:

package com.javainuse.config;

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.SimpleWsdl11Definition;
import org.springframework.ws.wsdl.wsdl11.Wsdl11Definition;

@EnableWs
@Configuration
public class WebServiceConfigConsultaWS extends WsConfigurerAdapter {

    @Bean
    public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
        MessageDispatcherServlet servlet = new MessageDispatcherServlet();
        servlet.setApplicationContext(applicationContext);

        return new ServletRegistrationBean(servlet, "/consultaws/*");
    }

    @Bean(name="consultaws")
    public Wsdl11Definition defaultWsdl11Definition() {
        SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
        wsdl11Definition.setWsdl(new ClassPathResource("/consultaws.wsdl"));

        return wsdl11Definition;
    }
}

端点:

package com.javainuse.endpoint;

import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

import com.m4u.vendasout.service.notificacao.VendasEfetivasRequisicao;
import com.m4u.vendasout.service.notificacao.VendasEfetivasResposta;

@Endpoint
public class WebServiceEndpointConsultaWS {

    private static final String NAMESPACE_URI = "http://notificacao.service.vendasout.m4u.com";

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "vendasEfetivasRequisicao")
    @ResponsePayload
    public VendasEfetivasResposta listarVendasEfetivasPeriodo(
            @RequestPayload VendasEfetivasRequisicao vendasRequisicao) {
        System.out.println("chegou");
        return null;
    }
}

通过SOAPUI调用:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:not="http://notificacao.service.vendasout.m4u.com">
   <soapenv:Header/>
   <soapenv:Body>
      <not:listarVendasEfetivasPeriodo>
         <!--Optional:-->
         <request>
            <usuario>test</usuario>
            <senha>test</senha>
            <inicio>2017-01-01</inicio>
            <fim>2018-01-01</fim>
            <marcador>1</marcador>
            <limite>2500</limite>
         </request>
      </not:listarVendasEfetivasPeriodo>
   </soapenv:Body>
</soapenv:Envelope>

结果控制台:

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

2018-01-07 09:52:56.672  INFO 1220 --- [           main] c.j.SpringBootHelloWorldApplication      : Starting SpringBootHelloWorldApplication on DESKTOP-SSIL7RR with PID 1220 (C:\Users\Robson\eclipse-workspace\TesteSOAPWSDL\target\classes started by Robson in C:\Users\Robson\eclipse-workspace\TesteSOAPWSDL)
2018-01-07 09:52:56.676  INFO 1220 --- [           main] c.j.SpringBootHelloWorldApplication      : No active profile set, falling back to default profiles: default
2018-01-07 09:52:56.737  INFO 1220 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@13e39c73: startup date [Sun Jan 07 09:52:56 BRST 2018]; root of context hierarchy
2018-01-07 09:52:57.352  INFO 1220 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'messageDispatcherServlet' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=webServiceConfig; factoryMethodName=messageDispatcherServlet; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/javainuse/config/WebServiceConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=webServiceConfigConsultaWS; factoryMethodName=messageDispatcherServlet; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/javainuse/config/WebServiceConfigConsultaWS.class]]
2018-01-07 09:52:57.661  INFO 1220 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'webServiceConfig' of type [class com.javainuse.config.WebServiceConfig$$EnhancerBySpringCGLIB$$8dc01f30] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-07 09:52:57.667  INFO 1220 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'webServiceConfigConsultaWS' of type [class com.javainuse.config.WebServiceConfigConsultaWS$$EnhancerBySpringCGLIB$$ca12c701] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-07 09:52:57.674  INFO 1220 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [class org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$fe599156] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-07 09:52:57.714  INFO 1220 --- [           main] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2018-01-07 09:52:58.175  INFO 1220 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-01-07 09:52:58.196  INFO 1220 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2018-01-07 09:52:58.199  INFO 1220 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.5
2018-01-07 09:52:58.350  INFO 1220 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-01-07 09:52:58.350  INFO 1220 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1617 ms
2018-01-07 09:52:58.566  INFO 1220 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'messageDispatcherServlet' to [/consultaws/*]
2018-01-07 09:52:58.567  INFO 1220 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2018-01-07 09:52:58.570  INFO 1220 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-07 09:52:58.570  INFO 1220 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-07 09:52:58.570  INFO 1220 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-07 09:52:58.570  INFO 1220 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2018-01-07 09:52:58.865  INFO 1220 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@13e39c73: startup date [Sun Jan 07 09:52:56 BRST 2018]; root of context hierarchy
2018-01-07 09:52:58.929  INFO 1220 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" 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)
2018-01-07 09:52:58.930  INFO 1220 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-07 09:52:58.957  INFO 1220 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-07 09:52:58.957  INFO 1220 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-07 09:52:58.998  INFO 1220 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-07 09:52:59.120  INFO 1220 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-01-07 09:52:59.166  INFO 1220 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-01-07 09:52:59.169  INFO 1220 --- [           main] c.j.SpringBootHelloWorldApplication      : Started SpringBootHelloWorldApplication in 2.87 seconds (JVM running for 3.246)
2018-01-07 09:53:04.222  INFO 1220 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'messageDispatcherServlet'
2018-01-07 09:53:04.222  INFO 1220 --- [nio-8080-exec-1] o.s.w.t.http.MessageDispatcherServlet    : FrameworkServlet 'messageDispatcherServlet': initialization started
2018-01-07 09:53:04.227  INFO 1220 --- [nio-8080-exec-1] o.s.ws.soap.saaj.SaajSoapMessageFactory  : Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
2018-01-07 09:53:04.247  INFO 1220 --- [nio-8080-exec-1] o.s.w.t.http.MessageDispatcherServlet    : FrameworkServlet 'messageDispatcherServlet': initialization completed in 25 ms
2018-01-07 09:53:04.317  WARN 1220 --- [nio-8080-exec-1] o.s.ws.server.EndpointNotFound           : No endpoint mapping found for [SaajSoapMessage {http://notificacao.service.vendasout.m4u.com}listarVendasEfetivasPeriodo]

我做错了什么? http://javainuse.com/spring/springbootsoapwebservice中的例子非常有效,但当我改为我的时候......

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

请尝试将soap服务位置更改为:

<soap:address
    location="http://localhost:8080/core/vendasout/consultaws"/>

另外,使用http://localhost:8080/consultaws.wsdl来获取WSDL。让我知道它是否适合你。