Announcement Announcement Module
Collapse
No announcement yet.
Http Support Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Http Support

    Hi,

    I was able to run the http sample without any problem. But I have been having problems trying to run a slightly different example -

    public interface RequestGateway {
    public Order createOrder(Order order);
    }

    public class Order implements Serializable {
    private Integer id;
    private String item;
    private Integer quantity;
    // setters and getters
    }

    public class OrderReceiver {
    public Order createOrder(Order order) {
    order.setId(1);
    return order;
    }
    }

    On the client side, I have -

    <int:gateway id="requestGateway"
    service-interface="org.springframework.integration.samples .http.RequestGateway"
    default-request-channel="requestChannel"/>

    <int:channel id="requestChannel"/>

    <int-http:outbound-gateway request-channel="requestChannel" url="http://localhost:8080/http/receiveGateway" http-method="POST"/>


    On the server side, I have -

    <bean name="/receiveGateway" class="org.springframework.integration.samples.htt p.CustomMessagingGateway" >
    <constructor-arg value="true" />
    <property name="requestChannel" ref="receiveChannel" />
    <property name="replyChannel" ref="responseChannel" />
    <property name="supportedMethods" >
    <list>
    <value>POST</value>
    <value>GET</value>
    </list>
    </property>

    <property name="messageConverters">
    <list>
    <bean class="org.springframework.integration.http.conver ter.SerializingHttpMessageConverter">
    <property name="supportedMediaTypes" value="application/x-java-serialized-object" />
    </bean>
    </list>
    </property>

    </bean>

    <int:channel id="receiveChannel"/>
    <int:channel id="responseChannel"/>

    <int:service-activator id="orderReceiver" input-channel="receiveChannel">
    <bean class="org.springframework.integration.samples.htt p.OrderReceiver"/>
    </int:service-activator>


    I keep getting an error -

    org.springframework.integration.MessagingException : Could not convert reply: no suitable HttpMessageConverter found for type [Order] and accept types [[text/html, image/gif, image/jpeg, */*;q=.2, */*;q=.2]]


    Please help.


    Thanks.

  • #2
    Actually had a problem with the http sample, using the latest SI jars (2.0.5.RELEASE), and wondering if anyone else had.
    The HttpClientDemo reply from the requestGateway should be 'Hello from the other side' based on the expression concat'd on the server, but only 'Hello' is returned.

    The debug level output from the logger is:

    DEBUG: org.springframework.integration.channel.DirectChan nel - preSend on channel 'receiveChannel', message: [Payload=Hello][Headers={content-type=text/plain;charset=UTF-8, errorChannel=org.springframework.integration.core. MessagingTemplate$TemporaryReplyChannel@501d5ebc, http_requestMethod=POST, connection=keep-alive, host=localhost:8080, replyChannel=org.springframework.integration.core. MessagingTemplate$TemporaryReplyChannel@501d5ebc, accept=[text/plain, */*], user-agent=Java/1.6.0_25, http_requestUrl=http://localhost:8080/http/receiveGateway, accept-charset=...
    DEBUG: org.springframework.integration.handler.ServiceAct ivatingHandler - ServiceActivator for [org.springframework.integration.handler.Expression EvaluatingMessageProcessor@3cecfaea] received message: [Payload=Hello][Headers={content-type=text/plain;charset=UTF-8, errorChannel=org.springframework.integration.core. MessagingTemplate$TemporaryReplyChannel@501d5ebc, http_requestMethod=POST, connection=keep-alive, host=localhost:8080, replyChannel=org.springframework.integration.core. MessagingTemplate$TemporaryReplyChannel@501d5ebc, accept=[text/plain, */*], user-agent=Java/1.6.0_25, http_requestUrl=http://localhost:8080/http/receiveGateway, accept-charset=...
    DEBUG: org.springframework.integration.handler.ServiceAct ivatingHandler - handler 'ServiceActivator for [org.springframework.integration.handler.Expression EvaluatingMessageProcessor@3cecfaea]' sending reply Message: [Payload=Hello from the other side][Headers={content-type=text/plain;charset=UTF-8, errorChannel=org.springframework.integration.core. MessagingTemplate$TemporaryReplyChannel@501d5ebc, http_requestMethod=POST, connection=keep-alive, host=localhost:8080, replyChannel=org.springframework.integration.core. MessagingTemplate$TemporaryReplyChannel@501d5ebc, accept=[text/plain, */*], user-agent=Java/1.6.0_25, http_requestUrl=http://localhost:8080/http/receiveGateway, accept-charset=...
    DEBUG: org.springframework.integration.channel.DirectChan nel - postSend (sent=true) on channel 'receiveChannel', message: [Payload=Hello][Headers={content-type=text/plain;charset=UTF-8, errorChannel=org.springframework.integration.core. MessagingTemplate$TemporaryReplyChannel@501d5ebc, http_requestMethod=POST, connection=keep-alive, host=localhost:8080, replyChannel=org.springframework.integration.core. MessagingTemplate$TemporaryReplyChannel@501d5ebc, accept=[text/plain, */*], user-agent=Java/1.6.0_25, http_requestUrl=http://localhost:8080/http/receiveGateway, accept-charset=...

    Comment


    • #3
      I'll try to dig more into what happened with the sample and will let you know. I think it was actually modified accidentally at some point with the extra wording in the expression without modifying configuration to accomodate for it.
      What you see is the correct reply being truncated based on the only known 'Content-Length" which is the original request. This would work fine if the reply had the same or smaller content length, but since it this case its bigger we need to set it explicitly.
      So here is how you can modify the code to make it do what you expect
      Code:
      <int:service-activator input-channel="receiveChannel" expression="payload + ' from the other side'"/>
      	
      <int:header-enricher input-channel="replyChannel">
      	<int:header name="Content-Length" expression="payload.length()"/>
      </int:header-enricher>
      However, I am still wondering if we have a bug on our side related to recalculating content-length
      I'll let you know.

      Comment


      • #4
        John, I thought i remembered something and I found this http://forum.springsource.org/showth...content-length
        So, yes we do have a bug.
        Could you please open a JIRA issue here https://jira.springsource.org/browse/INT or lem me know and I'll open it. I prefer when JIRA gets filed by the community, this way you'll get notified when it will be fixed. The way things are now, it will be fixed rather shortly and will make it into 2.1.M1 release which will also be shortly (next month).

        Comment


        • #5
          Oleg, quick note on this workaround: I needed to specify replyChannel in the service activator for the header-enricher to be applied, then it worked fine:
          Code:
          	<int:service-activator input-channel="receiveChannel" output-channel="replyChannel" expression="payload + ' from the other side'" />
          	
          	<int:header-enricher input-channel="replyChannel">
          		<int:header name="Content-Length" expression="payload.length()"/>
          	</int:header-enricher>
          And here's the JIRA:
          https://jira.springsource.org/browse/INT-2006

          Thanks, Oleg, for your help.
          John
          Last edited by John Thoms; Jul 23rd, 2011, 05:32 PM.

          Comment

          Working...
          X