Spring-WS SOAP 终结点 405 方法不允许

Spring-WS SOAP Endpoint 405 Method not allowed

您好,我正在尝试创建一个@endpoint SOAP 服务,但是当我尝试获取 WSDL 时,我得到一个 405 方法不允许。

这是我的服务端点:

@Endpoint
public class SubscribeMemberService {

        public static final String NAMESPACE_URI = "urn:v1.webservice.subscription.test.org";

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "subscribe")
    @ResponsePayload
    public SubscribeMemberResponse subscribe(@RequestPayload  SubscribeMemberRequest request) throws SubscribeMemberFault_Exception {
        LOG.info("request received: LastName:" + request.getName().getLastName());

            SubscribeMemberResponse response = new SubscribeMemberResponse();
            response.setInfoMessage("Subscription of  " + request.getName().getLastName());
            LOG.info("sending response:" + request.getName().getLastName());
            return response;

    }

}

还有我的 WS 配置:

@EnableWs
@Configuration
@ComponentScan("org.test")
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 = "subscribeMember")
        public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema subscribeMember) {
                DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
                wsdl11Definition.setPortTypeName("subscribeMemberPort");
                wsdl11Definition.setLocationUri("/ws");
                wsdl11Definition.setTargetNamespace(SubscribeMemberService.NAMESPACE_URI);
                wsdl11Definition.setSchema(subscribeMember);
                return wsdl11Definition;
        }

        @Bean
        public XsdSchema subscribeMemberSchema() {
                return new SimpleXsdSchema(new ClassPathResource("META-INF/wsdl/subscribeMember.xsd"));
        }
}

可能是 link 到 WebSecurityConfigurerAdapter?因为在 /ws/* 上我没有找不到 404,但我得到 405 not allowed。有什么想法吗?

注意:WebSecurityConfigurerAdapter class 中的安全过滤器是

protected void configure(HttpSecurity http) throws Exception {
        http.httpBasic()
                .and()
                .authorizeRequests()
                .anyRequest().hasRole("mySuperRole").and()
                .csrf().disable();
}

我找到了解决方案:

  1. 我禁用了 WebSecurityConfigurerAdapter 以确保这不是来自安全性的问题。
  2. 我在日志中发现一个问题:"SAAJ0511: Unable to create envelope from given source"
  3. 为了解决这个问题,我决定使用官方教程 (https://spring.io/guides/gs/producing-web-service/#_generate_domain_classes_based_on_an_xml_schema) 中的 maven 插件 "jaxb2-maven-plugin" 代替 "jaxws-maven-plugin"。我将 wsdl 文件移到了 /resources.
  4. 我通过本教程转换了我的 SOAP 异常:http://memorynotfound.com/spring-ws-add-detail-soapfault-exception-handling/
  5. 我重新启用了 WebSecurityConfigurerAdapter