Announcement Announcement Module
Collapse
No announcement yet.
How to integrate Spring-WS with existing web-app (2) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to integrate Spring-WS with existing web-app (2)

    I have a working web-app. I have inserted a webservice on it (spring-ws echo sample). Looking at "How to integrate Srping-WS with existing web-app" my web-app is working, but not my web-service. Can someone tell me what's wrong??

    --- This is the App - context -->
    Code:
    <bean id="messageHandlerAdapter" class="org.springframework.ws.transport.http.MessageHandlerAdapter">
            <property name="messageContextFactory">
                <bean class="org.springframework.ws.soap.saaj.SaajSoapMessageContextFactory"/>
            </property>
        </bean>
    	
        <bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="/index.html">controlServidoresController</prop>
                    <prop key="/versiones.html">versionesServidoresController</prop>
                    <prop key="/estadopaquetes.html">estadoPaquetesController</prop>
                </props>
            </property>
            <property name="defaultHandler" ref="messageDispatcher"/>
        </bean>
        
        <bean id="controllerHandlerAdapter" class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
         
        <!-- Spring-WS beans -->
        <bean id="messageDispatcher" class="org.springframework.ws.soap.SoapMessageDispatcher">
            <description>
                The MessageDispatcher is responsible for routing messages to endpoints.
            </description>
            <property name="endpointMappings">
                <ref local="payloadMapping"/>
            </property>
            <property name="endpointExceptionResolvers">
                <ref local="endpointExceptionResolver"/>
            </property>
        </bean>
    
        <bean id="payloadMapping" class="org.springframework.ws.soap.endpoint.PayloadRootQNameEndpointMapping">
            <property name="defaultEndpoint" ref="receptorFtpEndPoint" />
            <property name="interceptors">
                <list>
                    <ref local="validatingInterceptor"/>
                    <ref local="loggingInterceptor"/>
                </list>
            </property>
        </bean>
    
        <bean id="validatingInterceptor" class="org.springframework.ws.endpoint.PayloadValidatingInterceptor">
            <property name="schema" value="schemas/Alive.xsd"/>
            <property name="validateRequest" value="true"/>
            <property name="validateResponse" value="true"/>
        </bean>
    
        <bean id="loggingInterceptor" class="org.springframework.ws.endpoint.PayloadLoggingInterceptor">
        </bean>
    
        <bean id="receptorFtpEndPoint" class="nnn.ws.ReceptorFtpEndPoint">
            <property name="receptorFtpService" ref="receptorFtpService"/>
        </bean>
    
        <bean id="endpointExceptionResolver" class="org.springframework.ws.soap.endpoint.SimpleSoapExceptionResolver"/>
    
        <!-- "Business" (POJO) services -->
        <bean id="receptorFtpService" class="nnn.ws.service.impl.ReceptorFtpServiceImpl"/>
    --------- END -----

    This is my wsdl file....

    ---------
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions 
    	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        xmlns:tns="http://www.testing.com"
        xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        targetNamespace="http://www.testing.com/controlservidores">
    
    	<wsdl:import namespace="http://www.testing.com/controlservidores" location="schemas/Alive.xsd"/>
    
    	<wsdl:message name="aliveResponse">
    		<wsdl:part name="aliveResponse" type="xsd:string"/>
    	</wsdl:message>
    	
    	<wsdl:message name="aliveRequest">
    		<wsdl:part name="aliveRequest" type="xsd:Alive"/>
    	</wsdl:message>
    	
    	<wsdl:portType name="ReceptorFtp">
    		<wsdl:operation name="alive">
    			<wsdl:input message="tns:aliveRequest" name="aliveRequest" />
    			<wsdl:output message="tns:aliveResponse" name="aliveResponse" />
    		</wsdl:operation>
    	</wsdl:portType>
    	
    	<wsdl:binding name="ReceptorFtpSOAP" type="tns:ReceptorFtp">
    	<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    		<wsdl:operation name="alive">
    			<wsdlsoap:operation soapAction=""/>
    			<wsdl:input name="aliveRequest">
    				<wsdlsoap:body use="literal"/>
    			</wsdl:input>
    			<wsdl:output name="aliveRespose">
    				<wsdlsoap:body use="literal"/>
    			</wsdl:output>
    		</wsdl:operation>
    	</wsdl:binding>
    
    	<wsdl:service name="ReceptorFtp">
    		<wsdl:port binding="tns:ReceptorFtpSOAP" name="ReceptorFtpSOAP">
    			<wsdlsoap:address location="http://localhost:8080/controlservidores"/>
    		</wsdl:port>
    	</wsdl:service>
    </wsdl:definitions>
    -----

    And this is my web.xml file

    ------
    Code:
      <servlet>
        <servlet-name>controlservidoresweb</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
      </servlet>
    
      <servlet-mapping>
        <servlet-name>controlservidoresweb</servlet-name>
        <url-pattern>*.html</url-pattern>
      </servlet-mapping>
    ------


    Thanks in advance...

  • #2
    hallo salva,

    what does your log file say? is the soap request forwarded to the message dispatcher?
    I have seen you added it as default in your HandlerMapping. I have configured it
    explicitly:

    <prop key="/mywebservice_url">messageDispatcher</prop>

    Comment


    • #3
      ok i think i found your problem! your web.xml is configured to forward only requests that end with .html to the dispatcher servlet. you need a separate mapping for your webservice requests too:

      <servlet-mapping>
      <servlet-name>controlservidoresweb</servlet-name>
      <url-pattern>/webservice_url</url-pattern>
      </servlet-mapping>

      hope that helps!

      Comment


      • #4
        Thanks a lot... Now I have a new error, but I thing is working better...

        I have this error:

        Code:
        Could not complete request
        org.springframework.ws.soap.saaj.SaajSoapMessageException: Could not read 'Content-Type' header from message

        Comment


        • #5
          In order to help you, you need to provide more information.
          Turn on logging on DEBUG level for the springframework.ws package and post
          the output. Additionally log & post the soap request. You can use soapui for that purpose: http://www.soapui.org/

          Comment


          • #6
            Hello again,
            This is the new error... As you can see, the request goes to the "Testing endpoint mapping (PayloadRootQNameEndpointMapping)"

            This is the log:

            Code:
            2006-07-04 12:52:08,779 DEBUG [org.springframework.web.servlet.DispatcherServlet] DispatcherServlet with name 'controlservidoresweb' received request for [/controlservidores/receptorFtp]
            2006-07-04 12:52:08,779 DEBUG [org.springframework.web.servlet.DispatcherServlet] Testing handler map [[email protected]353f6] in DispatcherServlet with name 'controlservidoresweb'
            2006-07-04 12:52:08,779 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] Looking up handler for [/receptorFtp]
            2006-07-04 12:52:08,779 DEBUG [org.springframework.web.servlet.DispatcherServlet] Testing handler adapter [[email protected]07]
            2006-07-04 12:52:08,967 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] MessageDispatcher with name 'messageDispatcher' received request [org.springframework.ws.soap.saaj.SaajSoapMessage@158aeed]
            2006-07-04 12:52:08,967 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] Testing endpoint mapping [org.springframework.ws.soap.endpoint.PayloadRootQNameEndpointMapping@144569b]
            2006-07-04 12:52:09,107 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] Testing endpoint exception resolver [[email protected]cfaf6e]
            2006-07-04 12:52:09,138 WARN  [org.springframework.ws.soap.SoapMessageDispatcher] Endpoint invocation resulted in exception - responding with SOAP Fault
            org.springframework.ws.soap.saaj.SaajSoapEnvelopeException: Could not access envelope: org.jboss.axis.AxisFault: Content is not allowed in prolog.; nested exception is javax.xml.soap.SOAPException: org.jboss.axis.AxisFault: Content is not allowed in prolog.
            javax.xml.soap.SOAPException: org.jboss.axis.AxisFault: Content is not allowed in prolog.
            	at org.jboss.axis.MessagePart.getEnvelope(MessagePart.java:1107)
            	at org.springframework.ws.soap.saaj.SaajSoapMessage.getEnvelope(SaajSoapMessage.java:103)
            	at org.springframework.ws.soap.AbstractSoapMessage.getSoapBody(AbstractSoapMessage.java:33)
            	at org.springframework.ws.soap.AbstractSoapMessage.getPayloadSource(AbstractSoapMessage.java:47)
            	at org.springframework.ws.soap.endpoint.PayloadRootQNameEndpointMapping.getMessagePayloadElement(PayloadRootQNameEndpointMapping.java:48)
            	at org.springframework.ws.soap.endpoint.PayloadRootQNameEndpointMapping.resolveQName(PayloadRootQNameEndpointMapping.java:41)
            	at org.springframework.ws.soap.endpoint.AbstractQNameEndpointMapping.getLookupKeyForMessage(AbstractQNameEndpointMapping.java:32)
            	at org.springframework.ws.soap.endpoint.AbstractMapBasedSoapEndpointMapping.getEndpointInternal(AbstractMapBasedSoapEndpointMapping.java:109)
            	at org.springframework.ws.endpoint.AbstractEndpointMapping.getEndpoint(AbstractEndpointMapping.java:81)
            	at org.springframework.ws.MessageDispatcher.getEndpoint(MessageDispatcher.java:315)
            	at org.springframework.ws.MessageDispatcher.dispatch(MessageDispatcher.java:227)
            	at org.springframework.ws.MessageDispatcher.invoke(MessageDispatcher.java:209)
            	at org.springframework.ws.transport.http.MessageHandlerAdapter.handle(MessageHandlerAdapter.java:57)
            	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:684)
            	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
            	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
            	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:357)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            	at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
            	at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
            	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
            	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            	at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
            	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
            	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
            	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
            	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
            	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            	at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
            	at java.lang.Thread.run(Thread.java:595)
            Caused by: org.jboss.axis.AxisFault: Content is not allowed in prolog.
            	at org.jboss.axis.AxisFault.makeFault(AxisFault.java:99)
            	at org.jboss.axis.MessagePart.getAsSOAPEnvelope(MessagePart.java:691)
            	at org.jboss.axis.MessagePart.getEnvelope(MessagePart.java:1103)
            	... 41 more
            Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
            	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
            	at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
            	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
            	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
            	at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
            	at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
            	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
            	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
            	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
            	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
            	at javax.xml.parsers.SAXParser.parse(Unknown Source)
            	at org.jboss.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:257)
            	at org.jboss.axis.MessagePart.getAsSOAPEnvelope(MessagePart.java:684)
            	... 42 more
            2006-07-04 12:52:09,154 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] MessageDispatcher with name 'messageDispatcher' sends response [org.springframework.ws.soap.saaj.SaajSoapMessage@9db0ad]
            2006-07-04 12:52:09,201 DEBUG [org.springframework.web.servlet.DispatcherServlet] Null ModelAndView returned to DispatcherServlet with name 'controlservidoresweb': assuming HandlerAdapter completed request handling
            2006-07-04 12:52:09,201 DEBUG [org.springframework.web.servlet.DispatcherServlet] Successfully completed request
            2006-07-04 12:52:09,201 DEBUG [org.springframework.web.context.support.XmlWebApplicationContext] Publishing event in context [WebApplicationContext for namespace 'controlservidoresweb-servlet']: RequestHandledEvent: url=[/controlservidores/receptorFtp]; time=[422ms]; client=[127.0.0.1]; method=[POST]; servlet=[controlservidoresweb]; session=[671F206993FE439D713452FE98A4B6A9]; user=[null]; status=[OK]
            This is the SoapUI log:

            Code:
            12:52:08 : DEBUG : >> "POST /controlservidores/receptorFtp HTTP/1.1[\r][\n]"
            12:52:08 : DEBUG : >> "Content-Type: text/xml;charset=UTF-8[\r][\n]"
            12:52:08 : DEBUG : >> "SOAPAction: ""[\r][\n]"
            12:52:08 : DEBUG : >> "User-Agent: Jakarta Commons-HttpClient/3.0[\r][\n]"
            12:52:08 : DEBUG : >> "Host: localhost:8080[\r][\n]"
            12:52:08 : DEBUG : >> "Content-Length: 5[\r][\n]"
            12:52:08 : DEBUG : >> "[\r][\n]"
            12:52:08 : DEBUG : >> "Test1"
            12:52:09 : DEBUG : << "HTTP/1.1 500 Error Interno del Servidor[\r][\n]"
            12:52:09 : DEBUG : << "Server: Apache-Coyote/1.1[\r][\n]"
            12:52:09 : DEBUG : << "X-Powered-By: Servlet 2.4; JBoss-4.0.3SP1 (build: CVSTag=JBoss_4_0_3_SP1 date=200510231054)/Tomcat-5.5[\r][\n]"

            Comment


            • #7
              I think I have a problem with my wsdl file. After changing it. I have this new error...

              Code:
              2006-07-04 13:39:04,871 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] MessageDispatcher with name 'messageDispatcher' received request [org.springframework.ws.soap.saaj.SaajSoapMessage@199049]
              2006-07-04 13:39:04,871 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] Testing endpoint mapping [org.springframework.ws.soap.endpoint.PayloadRootQNameEndpointMapping@144569b]
              2006-07-04 13:39:04,980 DEBUG [org.springframework.ws.soap.endpoint.PayloadRootQNameEndpointMapping] Looking up endpoint for [{http://test.com/controlservidores}aliveString]
              2006-07-04 13:39:04,980 DEBUG [org.springframework.ws.endpoint.PayloadLoggingInterceptor] Request payload: <con:aliveString xmlns:con="http://test.com/controlservidores">OF0001</con:aliveString>
              2006-07-04 13:39:04,980 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] Testing endpoint adapter [org.springframework.ws.endpoint.MessageEndpointAdapter@157402b]
              2006-07-04 13:39:04,980 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] Testing endpoint adapter [org.springframework.ws.endpoint.PayloadEndpointAdapter@135f7f3]
              2006-07-04 13:39:04,980 DEBUG [org.springframework.ws.soap.SoapMessageDispatcher] Testing endpoint exception resolver [[email protected]cfaf6e]
              2006-07-04 13:39:04,996 WARN  [org.springframework.ws.soap.SoapMessageDispatcher] Endpoint invocation resulted in exception - responding with SOAP Fault
              java.lang.IllegalArgumentException: Invalid namespace
              	at org.springframework.util.Assert.isTrue(Assert.java:64)
              This is my new wdls file

              Code:
              <?xml version="1.0" encoding="UTF-8"?>
              <wsdl:definitions 
              	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:tns="http://test.com/controlservidores"
                  xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  targetNamespace="http://test.com/controlservidores">
              
              	<wsdl:import namespace="http://localhost:8080/controlservidores/schemas" location="Alive.xsd"/>
              
              	<wsdl:message name="aliveRequest">
              		<wsdl:part name="aliveString" type="tns:aliveRequest"/>
              	</wsdl:message>
              
              	<wsdl:message name="aliveResponse">
              		<wsdl:part name="theResponse" type="tns:aliveResponse"/>
              	</wsdl:message>
              
                 <wsdl:portType name="ReceptorFtpServicePortType">
                      <wsdl:operation name="alive">
                          <wsdl:input message="tns:aliveRequest" name="aliveRequest"/>
                          <wsdl:output message="tns:aliveResponse" name="aliveResponse"/>
                      </wsdl:operation>
                  </wsdl:portType>
              
                  <wsdl:binding name="ReceptorFtpServiceHttpBinding" type="tns:ReceptorFtpServicePortType">
                      <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
                      <wsdl:operation name="alive">
                          <wsdlsoap:operation soapAction=""/>
                          <wsdl:input name="aliveRequest">
                              <wsdlsoap:body use="literal"/>
                          </wsdl:input>
                          <wsdl:output name="aliveResponse">
                              <wsdlsoap:body use="literal"/>
                          </wsdl:output>
                      </wsdl:operation>
                  </wsdl:binding>
              
                  <wsdl:service name="ReceptorFtpService">
                      <wsdl:port binding="tns:ReceptorFtpServiceHttpBinding" name="ReceptorFtpServiceHttpPort">
                          <wsdlsoap:address location="http://localhost:8080/controlservidores/receptorFtp"/>
                      </wsdl:port>
                  </wsdl:service>
                  
              </wsdl:definitions>

              Comment


              • #8
                Solved. The wsdl file was the problem.

                Thanks.

                Comment

                Working...
                X