I have a message pipeline which starts with <http: outbound-gateway> element configured like so:
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.
<http:outbound-gateway id="html" request-channel="tickerChannel"
<http:uri-variable name="ticker" expression="payload" />
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:
During the integration test that runs using the <http:outbound-gateway> against the same URL my XPath handling breaks with NPE however.
Resource resource = context.getResource("/META-INF/spring/integration/initial.xml");
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:
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)???
<file:outbound-gateway id="mover" request-channel="htmlResponseChannel"
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: