Open

Description
i want to sent json by post method
after change integration configuration
and write test i send object but response is failed
<int-http:inbound-gateway id="inboundEmployeeSearchRequestGateway"
supported-methods="POST"
request-payload-type="org.springframework.integration.samples.rest.domain.Employee"
request-channel="employeeSearchRequest"
reply-channel="employeeSearchResponse"
mapped-response-headers="Return-Status, Return-Status-Msg, HTTP_RESPONSE_HEADERS"
path="/services/employee/{id}/search"
reply-timeout="50000"
>
@Test
public void testGetEmployeeAsJsonPOST() throws Exception {
Map<String, Object> employeeSearchMap = getEmployeeSearchMap("0");
final String fullUrl = "http://localhost:8080/rest-http/services/employee/{id}/search?format=json";
HttpHeaders headers = getHttpHeadersWithUserCredentials(new HttpHeaders());
headers.add("Accept", "application/json");
Employee em=new Employee(6, "ali akbar", "azizkhani");
HttpEntity<Employee> request = new HttpEntity<Employee>(em,headers);
ResponseEntity<?> httpResponse = restTemplate.exchange(fullUrl, HttpMethod.POST, request,EmployeeList.class, employeeSearchMap);
logger.info("Return Status :" + httpResponse.getHeaders().get("X-Return-Status"));
logger.info("Return Status Message :" + httpResponse.getHeaders().get("X-Return-Status-Msg"));
assertTrue(httpResponse.getStatusCode().equals(HttpStatus.OK));
ByteArrayOutputStream out = new ByteArrayOutputStream();
jaxbJacksonObjectMapper.writeValue(out, httpResponse.getBody());
logger.info(new String(out.toByteArray()));
}
Activity
artembilan commentedon May 26, 2014
Your changes works for me. Share, please, the StackTrace
artembilan commentedon May 27, 2014
Looks like you changed something else, e.g. in the
EmployeeSearchService
artembilan commentedon May 27, 2014
Do you mean this:
?
What is your point? Just to check that we can transfer request object to response?
Although I don't see concern to add it to the sample, but there is need to understand the goal.
Thanks
artembilan commentedon May 27, 2014
Strange: it works for me again:
Or you are using some old SAMPLES version, or I am wrong that test it against my Gradle branch.
I think we will add your tweaks to this sample, but already after we commit Gradle migration.
What might cause the issue, that I use Gradle and its Jetty pluging, but Maven sample uses Tomcat pluging.
As the conclusion: all your modifications are correct and have the right to life
artembilan commentedon Jun 4, 2014
Well, does it say that you haven't shown entire changes to the sample?
Can you do it now?