不允许使用Spring-WS SOAP端点405方法

时间:2017-10-09 13:09:46

标签: spring-boot spring-security spring-ws

您好我正在尝试创建@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"));
        }
}

它可以链接到WebSecurityConfigurerAdapter吗?因为在/ ws / *我没有找到404,但我得不到405。有什么想法吗?

注意:WebSecurityConfigurerAdapter类中的安全筛选器是

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

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:

  1. 我禁用了WebSecurityConfigurerAdapter,以确保这不是来自安全性的问题。
  2. 我在日志中发现了一个问题:“SAAJ0511:无法从给定来源创建信封”
  3. 为了解决这个问题,我决定使用官方tuto(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