Spring Tomcat Deployment: Soap call returns "405: Method not allowed" -
i running webapp application publishes rest , soap services. both of them working fine when run app gradle run (spring-boot plugin) or java application sts. soap services work when called soapui or $.soap ajax invocation index.html whenever application run gradle run or sts. i've tried deploy webapp on tomcat 7. webapp static content , rest services working fine. problem soap services not work.
i'm getting following error code, either index.html $.soap calls or soapui tests:
post http://localhost:8080/soap/ 405 (method not allowed)
this servlet-context.xml file:
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> <!-- dispatcherservlet context: defines servlet's request-processing infrastructure enables spring mvc @controller programming model --> <mvc:annotation-driven /> <!-- handles http requests /resources/** efficiently serving static resources in ${webapproot}/resources directory --> <mvc:resources mapping="/resources/**" location="/resources/" /> <!-- resolves views selected rendering @controllers .jsp resources in /web-inf/views directory --> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/views/" /> <property name="suffix" value=".jsp" /> </bean> <context:component-scan base-package="com.stw_2015.app" /> </beans>
and structure of @endpoint annotated class:
@endpoint public class soapcontroller { private static final string namespace_uri = "http://com.stw_2015.app/soap"; private static final logger logger = loggerfactory.getlogger(soapcontroller.class); @payloadroot(namespace = namespace_uri, localpart = "registeractionrequest") @responsepayload public registeractionresponse registeraction ( @requestpayload registeractionrequest registeractionrequest) { ................ } }
possibly, reason post requests soap service being rejected spring. there way enable them? rest services requests, know @requestmapping annotated methods can annotated or post requests listeners. however, soap service, don't know.
can me out? thank you!
pd: please tell me if should paste other file contents.
i managed solve problem. missing key point. soap services using messagedispatcherservlet bean defined this:
@enablews @configuration public class soapwebservicesconfig extends wsconfigureradapter { @bean public servletregistrationbean messagedispatcherservlet(applicationcontext applicationcontext) { messagedispatcherservlet servlet = new messagedispatcherservlet(); servlet.setapplicationcontext(applicationcontext); servlet.settransformwsdllocations(true); return new servletregistrationbean(servlet, "/soap/*"); } // http://localhost:8080/soap/soap_description.wsdl -> accesible @bean(name = "soap_description") public defaultwsdl11definition defaultwsdl11definition(xsdschema actionsschema) { defaultwsdl11definition wsdl11definition = new defaultwsdl11definition(); wsdl11definition.setporttypename("soapport"); wsdl11definition.setlocationuri("/soap"); wsdl11definition.settargetnamespace("http://com.stw_2015.app/soap"); wsdl11definition.setschema(actionsschema); return wsdl11definition; } @bean public xsdschema actionsschema() { return new simplexsdschema(new classpathresource("soap_description.xsd")); } }
as said, these services working fine if run sts or gradle run. problem servlet not defined on web.xml file. file this:
<?xml version="1.0" encoding="utf-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- definition of root spring container shared servlets , filters --> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/root-context.xml</param-value> </context-param> <!-- creates spring container shared servlets , filters --> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <!-- processes application requests --> <servlet> <servlet-name>spring-ws</servlet-name> <servlet-class>org.springframework.ws.transport.http.messagedispatcherservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>appservlet</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/appservlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring-ws</servlet-name> <url-pattern>/soap/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>appservlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
before that, appservlet servlet (which configured servlet-context.xml showed) trying handle "/soap/*" requests. now, spring-ws servlet handling requests, while appservlet handling rest of them.
finally, had create file this, called spring-ws-servlet.xml , located @ "web-inf" folder:
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> <!-- dispatcherservlet context: defines servlet's request-processing infrastructure enables spring mvc @controller programming model --> <mvc:annotation-driven /> <context:component-scan base-package="com.stw_2015.app" /> </beans>
Comments
Post a Comment