0

I need to write a simple HTTP client to make simple GET request and get JSON response using Spring integration. Call fails with no message in exception: org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error. I tried debugging Spring code and did it successfully till I have source code, namely till in the method AbstractMessageHandler.handleMessage(Message message) abstract handleMessageInternal(Message message) has been called which threw exception saying that request with URL = http://example.com?q={q}&authKey={authKey}&rows={rows}&page={page}&filter={filter} failed. URL looked exactly as I quoted, i.e. expressions have not been executed.

Payload in the message was always as it should be - instance if ZtInput with correct field values.

Could anyone give me an idea what to do?

Here is spring-integration-zt-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-http="http://www.springframework.org/schema/integration/http"
xmlns:oxm="http://www.springframework.org/schema/oxm" 
xsi:schemaLocation="http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http-2.1.xsd
    http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-3.0.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">

<int:channel id="InChannelZt"></int:channel>
<int:channel id="OutChannelZt"></int:channel>

<!-- Gateway Start -->
<int:gateway id="ZtGateway" default-request-timeout="5000" default-reply-timeout="5000" 
default-request-channel="InChannelZt" service-interface="com.example.service.ZtService">
    <int:method name="getResults" request-channel="InChannelZt" reply-channel="OutChannelZt" />
</int:gateway>  

<int-http:outbound-gateway id="locationZtGateway"
                           request-channel="InChannelZt" 
                           reply-channel="OutChannelZt"
                           url="${zt_url}?q={q}&amp;authKey={authKey}&amp;rows={rows}&amp;page={page}&amp;filter={filter}"
                           http-method="GET"
                           reply-timeout='5000'                            
                           expected-response-type="com.example.vo.ZtResponse">
        <int-http:uri-variable name="q" expression="payload.getQ()"/>
       <int-http:uri-variable name="authKey" expression="payload.getAuthKey()"/>
       <int-http:uri-variable name="rows" expression="payload.getRows()"/>
       <int-http:uri-variable name="page" expression="payload.getPage()"/>
       <int-http:uri-variable name="filter" expression="payload.getFilter()"/>
</int-http:outbound-gateway>

and two classes mentioned in it:

import com.xxxx.vo.ZtInput;
import com.xxxx.vo.ZtResponse;
public interface ZtService {
    ZtResponse getSearchResults(ZtInput ztInput);
}

Payload:

public class ZtInput {

private String q; //=pink
private String authKey = "baef7f8e39c53f852c8a14b7f6018b58";
private String rows="20";
private String page="1";
private String filter = "";


public ZtInputVO() {
}
public String getQ() {
    return q;
}
public void setQ(String q) {
    this.q = q;
}
public String getAuthKey() {
    return authKey;
}
public void setAuthKey(String authKey) {
    this.authKey = authKey;
}
public String getRows() {
    return rows;
}
public void setRows(String rows) {
    this.rows = rows;
}
public String getPage() {
    return page;
}
public void setPage(String page) {
    this.page = page;
}
public String getFilter() {
    return filter;
}
public void setFilter(String filter) {
    this.filter = filter;
}
}

1 Answer 1

0

The URI in the exception is the original (unexpanded URI); the expansion is performed into a different variable. (We should/will change that to log the expanded URI). But the bottom line is your server didn't like the expanded URI and returned a 500 internal server error.

You can use a network/tcp monitor (eclipse has one built in or you can use wireshark) to examine the actual URL sent to the server. You can also look at the server logs, if enabled.

Or, in the debugger, step down to line 415 (in the current source code - version 4.0.4) and examine realUri.

EDIT: The exception now includes the expanded URI (currently available in 4.0.5.BUILD-SNAPSHOT and 4.1.0.BUILD-SNAPSHOT).

1
  • Thank you very much. I indeed was mislead by the exception message that included unprocessed URI. It is very good that you fixed it. Oct 6, 2014 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.