3

Hi I'm trying to make an @endpoint SOAP service, but when I try to get the WSDL I get an 405 Method Not Allowed.

There is my service endpoint :

@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;

    }

}

And there is my WS config :

@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"));
        }
}

Could it be link to the WebSecurityConfigurerAdapter? Because on the /ws/* I don't have an 404 not found, but I get 405 not allowed. Any ideas?

Note : the security filter in the WebSecurityConfigurerAdapter class is

protected void configure(HttpSecurity http) throws Exception {
        http.httpBasic()
                .and()
                .authorizeRequests()
                .anyRequest().hasRole("mySuperRole").and()
                .csrf().disable();
}
user1810567
  • 1,129
  • 3
  • 14
  • 22
  • Maybe I found the issue "Getting a 405 (Method not Allowed) error code when accessing a SOAP service with a browser (i.e. via a GET) is actually correct behavior: all SOAP HTTP access is done via a POST, not a GET. You can try pointing a SOAP client at the WSDL ( SoapUI for example), and see if that works instead." https://stackoverflow.com/questions/27198987/soap-webservice-endpoint-from-wsdl I'll test with SoapUI – user1810567 Oct 09 '17 at 13:13
  • No it's not working with SOAP UI : "Error loading [http://localhost:8080/subscription-webservice/v1/ws/SubscribeMemberService?wsdl]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after nul." And anyway the wsdl file should be accessible via GET. – user1810567 Oct 09 '17 at 13:17

1 Answers1

1

I found the solution:

  1. I disabled the WebSecurityConfigurerAdapter to be sure that was not an issue coming from the security.
  2. I discover an issue in the logs : "SAAJ0511: Unable to create envelope from given source"
  3. To fix the issue I decided to use the maven plugin "jaxb2-maven-plugin" from the official tuto (https://spring.io/guides/gs/producing-web-service/#_generate_domain_classes_based_on_an_xml_schema) in place of "jaxws-maven-plugin". And I moved the wsdl files in /resources.
  4. I converted my SOAP exception with this tutorial : http://memorynotfound.com/spring-ws-add-detail-soapfault-exception-handling/
  5. I re-enabled the the WebSecurityConfigurerAdapter
user1810567
  • 1,129
  • 3
  • 14
  • 22
  • can you please look at my question. https://stackoverflow.com/questions/72578781/soap-web-service-is-sending-response-even-when-the-request-does-not-have-okta-to – M S Kulkarni Jun 12 '22 at 02:57