Announcement Announcement Module
Collapse
No announcement yet.
HttpRequestHandlingMessagingGateway Support for Multiple HTTP Methods/Same Endpoint Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HttpRequestHandlingMessagingGateway Support for Multiple HTTP Methods/Same Endpoint

    I have two different messaging configurations that are both kicked off by HttpRequestHandlingMessagingGateway via http:inbound-gateway. Both of them use the same value for the name of the gateway endpoint URL. However, one supports GET while the other supports PUT.

    I am running an integration test using RestTemplate as my client. When I make a restTemplate.getForObject call, I get a 405 Method Not Allowed error. If I change just one of the endpoints to be anything different, then it works.

    I was curious if HttpRequestHandlingMessagingGateway had been tested for this case or if I am doing something wrong.

    Any insight is appreciated.

    Thanks.

  • vbose
    replied
    Originally posted by vbose View Post
    Thanks so much. I will post my example with tests.

    Regards,
    Vigil
    Ok. I completed the sample with functional test included and it looks good. I am ready to post the sample to the repository.

    Thanks,
    Vigil

    Leave a comment:


  • vbose
    replied
    Thanks so much. I will post my example with tests.

    Regards,
    Vigil

    Leave a comment:


  • ghillert
    replied
    Hi Vigil,

    I think I can help with this. The Spring Integration Samples project is hosted on GitHub:

    https://github.com/SpringSource/spri...ration-samples

    I have documented the contribution process on the Spring Integration Samples Wiki:

    https://github.com/SpringSource/spri...n-samples/wiki

    I hope it provides all the necessary steps you need. The Spring Integration Samples, project is basically organized into the following categories:
    • basic
    • intermediate
    • advanced
    • application

    Pick the category appropriate to your sample. Also, if possible, please provide some documentation for your sample. Just place a README.md in your sample directory. Also, the Spring Integration Samples project is currently using Maven (although we still target to migrate the Samples project to Gradle eventually). Also, we would really appreciate any unit/functional test you can provide for your sample (But don't dispair, we can help you with that).

    Please let us know if you have any questions. We are looking forward to your Sample!! THANKS!

    Cheers,

    Leave a comment:


  • vbose
    replied
    I was going to ask that question to SpringSource. I am more than willing to write one example on this since I struggled a lot in finding a solution and I would like others to benefit from the experience I got using Spring Integration and Spring MVC REST support. By the way, our application is a bit complex because it supports both SOAP Web services and REST style access support and the security configuration for REST is a bit more involved. How do I post the example to Spring Repository?

    Leave a comment:


  • oleg.zhurakousky
    replied
    Cool, great to hear

    Here is the question
    Would you be abel and willing to provide a very simple example of 'path' usage? We would include it with our samples so others can benefit.
    I figures you probably have something rather simple now and are willing to share. Let me know

    Leave a comment:


  • vbose
    replied
    The following Dispatcher Servlet url-pattern configuration worked for me. I changed the url-pattern from /services/cis/* to /* and now everything working.

    Code:
    <servlet>
    			<servlet-name>Destiny Customer Information Search Restful Web Service</servlet-name>
    		    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		    <init-param>
    		      <param-name>contextConfigLocation</param-name>
    		      <param-value></param-value>
    		    </init-param>
    		    <load-on-startup>2</load-on-startup>
    		</servlet>
    		<servlet-mapping>
    		    <servlet-name>Destiny Customer Information Search Restful Web Service</servlet-name>
    		    <url-pattern>/*</url-pattern>
    		</servlet-mapping>

    Leave a comment:


  • vbose
    replied
    The following is what I configured for Dispatcher Servlet in web.xml. Is the issue related to url-pattern? I am also supporting the regular SOAP web service within the same application and the url pattern for Spring Web Services mapped to /services and that is all working. It is the REST part that is not working. My gut feeling is that it is to do with the url-pattern configured with Dispatcher Servlet. All rest calls are mapped to /services/cis/*. Kindly offer suggestions or recommendations.

    Code:
    <servlet>
    			<servlet-name>Destiny Customer Information Search Restful Web Service</servlet-name>
    		    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		    <init-param>
    		      <param-name>contextConfigLocation</param-name>
    		      <param-value></param-value>
    		    </init-param>
    		    <load-on-startup>2</load-on-startup>
    		</servlet>
    		<servlet-mapping>
    		    <servlet-name>Destiny Customer Information Search Restful Web Service</servlet-name>
    		    <url-pattern>/services/cis/*</url-pattern>
    		</servlet-mapping>
    
    
    <servlet>
    		        <servlet-name>ws</servlet-name>
    		        <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    		        <init-param>
    					<param-name>transformWsdlLocations</param-name>
    					<param-value>true</param-value>
    				</init-param>
    				<load-on-startup>1</load-on-startup>
    		</servlet>
    		<servlet-mapping>
              <servlet-name>ws</servlet-name>
                  <url-pattern>/services</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
                  <servlet-name>ws</servlet-name>
                  <url-pattern>*.wsdl</url-pattern>
            </servlet-mapping>
            <mime-mapping>
            	  <extension>xsd</extension>
            	  <mime-type>text/xml</mime-type>
        	</mime-mapping>
    Thanks,
    Vigil

    Leave a comment:


  • oleg.zhurakousky
    replied
    Could you please post your entire configuration specific to this service? And I am also assuming you do have DispatcherServlet, ContextLoaderListener etc., configured in your web.xml

    Leave a comment:


  • vbose
    replied
    Originally posted by oleg.zhurakousky View Post
    You should omit the context path. So it should be path=/services/cis... Is that what you have?
    Yes. That's what I have.

    Vigil

    Leave a comment:


  • oleg.zhurakousky
    replied
    You should omit the context path. So it should be path=/services/cis... Is that what you have?

    Leave a comment:


  • vbose
    replied
    Thanks Mark. I added UriPathHandlerMapping to the SI application context. But still I get the same result. The below log snippet says that No mapping found for the request with URI /cis-ws/services/cis/fname/Rahul/lname/Bose/dln/1234567/dob/2011-10-11/photo. The first part of the URI is the context path which I do not want to map. For all other mappings, I have the URL mapped to /service/cis/..... Did I miss any other configuration?

    Code:
     WARN [org.springframework.web.servlet.PageNotFound] - No mapping found for HTTP request with URI [/cis-ws/services/cis/fname/Rahul/lname/Bose/dln/1234567/dob/2011-10-11/photo] in DispatcherServlet with name 'Destiny Customer Information Search Restful Web Service'
    Regards,
    Vigil

    Leave a comment:


  • Mark Fisher
    replied
    Vigil,

    Try just adding this one bean to your config:
    Code:
    <bean class="org.springframework.integration.http.inbound.UriPathHandlerMapping"/>
    That's the handler mapping implementation that is aware of inbound Spring Integration adapter's with "path" attributes.

    Leave a comment:


  • vbose
    replied
    Originally posted by oleg.zhurakousky View Post
    Actually, this issue has already been addressed. See - https://jira.springsource.org/browse/INT-1677
    If you try the latest snapshot you can now use 'path' attribute to specify the path and its variables (e.g., path="/gateway/fname/{f}/lname/{l}) and the 'id' has been re-factored to be xsd:string so it is just a name that would be used for mapping. So now you can simply have two different gateways with different names.
    Is the above configuration really working. The following is my configuration and I keep getting no mapping found error and the response errors out with HTTP status 404 Not Found. I am having hard time getting this to work. I would really appreciate if someone could throw some light into what might be the root cause.

    SI application Context snippet.

    Code:
    <int-http:inbound-gateway id="inboundCustomerRestfulPhotoRequestGateway"		
    		supported-methods="GET, POST" 
    		request-channel="customerRestfulPhotoRequest"
    		reply-channel="customerRestfulPhotoResponse"		
    		mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS"		
    		view-name="/photo" 		
    		path="/services/cis/fname/{fname}/lname/{lname}/dln/{dln}/dob/{dob}/photo"
    		reply-timeout="50000" >
    		
    		<int-http:header name="fname" expression="#pathVariables.fname"/>
    		<int-http:header name="lname" expression="#pathVariables.lname"/>
    		<int-http:header name="dln" expression="#pathVariables.dln"/>
    		<int-http:header name="dob" expression="#pathVariables.dob"/>
    		
    	</int-http:inbound-gateway>
    
    
           <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
    		<property name="order" value="1" />	
    		<property name="defaultContentType" value="application/xml"/>	
    		<property name="ignoreAcceptHeader" value="true" />
    		<property name="favorParameter" value="true"/>  
    		<property name="mediaTypes">
    			<map>
    				<entry key="json" value="application/json" />
    				<entry key="xml" value="application/xml" />				
    			</map>
    		</property>
    		<property name="defaultViews">
    			<list>
    				<bean
    					class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
    				<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
    					<constructor-arg ref="marshaller"/>					
    				</bean>				
    			</list>
    		</property>				
    	</bean>
    Server Log Snippet:

    Code:
    2011-11-14 17:29:40,987 DEBUG [org.springframework.security.access.vote.AffirmativeBased] - Voter: org.sp[email protected]14bbd50, returned: 1
    2011-11-14 17:29:41,050 DEBUG [org.springframework.security.web.access.intercept.FilterSecurityInterceptor] - Authorization successful
    2011-11-14 17:29:41,050 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'org.springframework.integration.internalMessagingAnnotationPostProcessor'
    2011-11-14 17:29:41,050 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'org.springframework.integration.config.IdGeneratorConfigurer#0'
    2011-11-14 17:29:41,050 DEBUG [org.springframework.security.web.access.intercept.FilterSecurityInterceptor] - RunAsManager did not change Authentication object
    2011-11-14 17:29:41,050 DEBUG [org.springframework.security.web.FilterChainProxy] - /services/cis/fname/Rahul/lname/Bose/dln/1234567/dob/2011-10-11/photo reached end of additional filter chain; proceeding with original chain
    2011-11-14 17:29:41,097 DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'Destiny Customer Information Search Restful Web Service' processing POST request for [/cis-ws/services/cis/fname/Rahul/lname/Bose/dln/1234567/dob/2011-10-11/photo]
    2011-11-14 17:29:41,097 WARN [org.springframework.web.servlet.PageNotFound] - No mapping found for HTTP request with URI [/cis-ws/services/cis/fname/Rahul/lname/Bose/dln/1234567/dob/2011-10-11/photo] in DispatcherServlet with name 'Destiny Customer Information Search Restful Web Service'
    2011-11-14 17:29:41,097 DEBUG [org.springframework.security.web.context.HttpSessionSecurityContextRepository] - The HttpSession is currently null, and the HttpSessionSecurityContextRepository is prohibited from creating an HttpSession (because the allowSessionCreation property is false) - SecurityContext thus not stored for next request
    2011-11-14 17:29:41,097 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
    Thanks,
    Vigil

    Leave a comment:


  • vbose
    replied
    What namespace configuration should we use to avail of the new feature. http://www.springframework.org/schema/integration/http http://www.springframework.org/schem...n-http-2.0.xsd or http://www.springframework.org/schema/integration/http http://www.springframework.org/schem...n-http-2.1.xsd.

    2.1 is complaining that it is not found. The new "path" element of http inbound gatewat does not exist in 2.0 xsd version

    Leave a comment:

Working...
X