You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java SOAP Web服务报错:No endpoint mapping found 求助

解决SOAP Web服务"No endpoint mapping found"报错
  • 先核对@PayloadRoot的命名空间和本地名称
    报错里的请求是{http://api.com}getCountryRequest,所以你的端点方法上的@PayloadRoot必须完全对应,一点都不能错:

    @PayloadRoot(namespace = "http://api.com", localPart = "getCountryRequest")
    @ResponsePayload
    public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) {
        // 你的业务逻辑
    }
    

    命名空间要和请求里的完全一致,本地名称(也就是getCountryRequest)大小写也得对,SOAP对这些是严格匹配的。

  • 检查WebService配置类的关键参数
    打开你的WebServiceConfig,重点看这几个地方:

    @Configuration
    @EnableWs
    public class WebServiceConfig extends WsConfigurerAdapter {
        @Bean
        public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
            DefaultWsdl11Definition wsdlDef = new DefaultWsdl11Definition();
            wsdlDef.setPortTypeName("CountriesPort");
            wsdlDef.setLocationUri("/ws"); // 这个是服务的访问前缀,比如你要访问http://localhost:8080/ws
            wsdlDef.setTargetNamespace("http://api.com"); // 必须和XSD、@PayloadRoot里的命名空间一致
            wsdlDef.setSchema(countriesSchema);
            return wsdlDef;
        }
    
        @Bean
        public XsdSchema countriesSchema() {
            return new SimpleXsdSchema(new ClassPathResource("countries.xsd"));
        }
    }
    

    尤其是targetNamespace和locationUri,前者错了会导致命名空间不匹配,后者错了会导致你访问的路径根本不对。

  • 确认请求的SOAP消息格式
    别光看代码,看看你实际发的请求是不是符合要求,比如正确的请求体应该是这样的:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://api.com">
       <soapenv:Header/>
       <soapenv:Body>
          <api:getCountryRequest>
             <api:name>Spain</api:name>
          </api:getCountryRequest>
       </soapenv:Body>
    </soapenv:Envelope>
    

    重点是getCountryRequest必须在http://api.com这个命名空间下,前缀叫什么无所谓,但命名空间不能错。

  • 删掉没用的配置
    你加的management.endpoints.web.exposure.*是给Spring Boot监控用的,和SOAP服务半毛钱关系都没有,直接删掉。spring.webservices.expose-all-endpoints=true如果端点本身配置对了才有用,要是端点没被Spring扫到,开这个也白搭——所以检查下你的端点类是不是和启动类在同一个包或者子包下,要是不在,就得给@SpringBootApplication加scanBasePackages指定扫描路径。

  • 看启动日志确认端点是否注册
    启动项目后搜日志里的"Endpoint registered",要是能看到getCountryRequest相关的注册日志,说明端点配置没问题,问题出在请求上;要是看不到,就是端点没被Spring扫描到,得调整包扫描的配置。

内容的提问来源于stack exchange,提问作者Rusydy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 04:25:41