2017-02-24 60 views

回答

0

HttpRequestExecutingMessageHandler做到这一点:

if (this.expectReply) { 
    ... 
    AbstractIntegrationMessageBuilder<?> replyBuilder = null; 
    if (httpResponse.hasBody()) { 
     Object responseBody = httpResponse.getBody(); 
     replyBuilder = (responseBody instanceof Message<?>) ? 
          this.getMessageBuilderFactory().fromMessage((Message<?>) responseBody) : this.getMessageBuilderFactory().withPayload(responseBody); 

    } 
    else { 
     replyBuilder = this.getMessageBuilderFactory().withPayload(httpResponse); 
    } 
       replyBuilder.setHeader(org.springframework.integration.http.HttpHeaders.STATUS_CODE, httpResponse.getStatusCode()); 
    return replyBuilder.copyHeaders(headers).build(); 
    } 
return null; 

所以,如果你不使用<int-http:outbound-channel-adapter>你肯定得到一些答复,会有那么HttpHeaders.STATUS_CODE头与HttpStatus.NO_CONTENT的价值。

正如您看到消息的​​取决于httpResponse.hasBody()的,我想在HttpStatus.NO_CONTENT情况下,确实没有body。所以,有效载荷是一个完整的ResponseEntity

现在,请分享更多信息它是如何为您工作的?你如何获得null​​?

+0

感谢您的回复。 UI层正在检查'responseXML'(即'XMLHttpRequest.responseXML')。由于它变为空,UI层失败。我甚至用'XMLHttpRequest.response'验证过,但它也是空的。顺便说一句,我正在使用IE浏览器。如果您需要任何其他信息,请告诉我。 –

+0

那么,你必须将更多的配置从控制器共享到这个网关并返回。没有更多的信息,目前尚不清楚哪一步可以帮助你。浏览器在这里并不重要 –

+0

对不起,延迟回复。服务提供商已经提供了一个标题Use-200-on-204-response,其中204响应将被转换为200。但似乎出站网关不接受自定义标题。我正在使用'MessageBulider'设置标题。我错过配置中的任何东西吗? –

相关问题