Announcement Announcement Module
Collapse
No announcement yet.
<http:outbound-gateway> produces upexpected result Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <http:outbound-gateway> produces upexpected result

    I have a message pipeline which starts with <http: outbound-gateway> element configured like so:

    Code:
    <http:outbound-gateway id="html" request-channel="tickerChannel"
    
    		url="http://finance.yahoo.com/q/op?s={ticker}+Options" 
    		http-method="POST"
    		expected-response-type="java.lang.String" 
    		charset="UTF-8"
    		reply-channel="htmlResponseChannel">
     
    		<http:uri-variable name="ticker" expression="payload"  />
    
    	</http:outbound-gateway>
    The resulting response message then gets transformed via <object-to-string-transformer> and ends up on a <service-activator> that grabs the HTML string, passes it via JTidy and into XPath to feed some business logic of the app.

    In unit tests I bypass the above <http:outbound-gateway> by instead using the source code view of the HTML page obtained from the above URL (i.e. http://finance.yahoo.com/q/op?s=SLW+Options like so:
    Code:
    Resource resource = context.getResource("/META-INF/spring/integration/initial.xml");
    During the integration test that runs using the <http:outbound-gateway> against the same URL my XPath handling breaks with NPE however.

    While debugging I can see the correct URL is used all the way in Spring and is handed off to HttpClient, but then the response has HTML contents different from the contents which one gets by going to that URL manually. To confirm my finding I used the following configuration:

    Code:
    <file:outbound-gateway id="mover" request-channel="htmlResponseChannel"
                reply-channel="tickerMessageHandlerChannel"
                directory="E:\source\Daedalus\quote-provider\src\main\resources\META-INF\spring\integration\"
                delete-source-files="true"/>
    and indeed can see that above behavior is the case. The page thus obtained has: Error: Please enter a ticker symbol. which leads me to believe that the ticker (SLW in this case) was somehow not properly passed to yahoo (it's clearly not recognized by it)???

    I'm not sure what could lead to that effect (whether it's misconfiguration on my part or some encoding issues at play - I noticed some mentions of them in a couple of threads here on the forum), could someone please lend me a hand with this or offer some insights?

    Here are relevant version numbers from pom.xml:
    Code:
                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    		<spring.version>3.0.7.RELEASE</spring.version>
    		<spring.integration.version>2.1.4.RELEASE</spring.integration.version>
    		<log4j.version>1.2.16</log4j.version>
    		<junit.version>4.10</junit.version>
    		<commons-io.version>2.4</commons-io.version>
    		<jtidy.version>r938</jtidy.version>

    TIA.
    Simeon

  • #2
    You should be doing
    Code:
    http-method="GET"
    not POST.

    Comment

    Working...
    X