2016-09-29 74 views
0

我在我的项目中使用了Spring集成。我有RESTful类型的POST Web服务,它接受多部分/表单数据类型。我知道int-http:outbound-gateway可以用来执行web服务。使用Spring集成将多部分/表单数据参数传递给RESTful webservice

但我不知道如何将文件类型(multipart/form-data)传递给消息并在int-http:outbound-gateway中使用它们。

为了得到一个想法,以下是POSTMAN客户端的屏幕打印,其中传递了multipart/form-data类型的参数。 enter image description here

我想通过将参数合并到消息中,以相同的方式将参数传递给int-http:outbound-gateway。关于如何实现所需功能的任何想法?如果您需要任何其他信息,请告诉我。

回答

0

HttpRequestExecutingMessageHandler有这样的代码:

else if (content instanceof Map) { 
     // We need to check separately for MULTIPART as well as URLENCODED simply because 
     // MultiValueMap<Object, Object> is actually valid content for serialization 
     if (this.isFormData((Map<Object, ?>) content)) { 
      if (this.isMultipart((Map<String, ?>) content)) { 
       contentType = MediaType.MULTIPART_FORM_DATA; 
      } 
      else { 
       contentType = MediaType.APPLICATION_FORM_URLENCODED; 
      } 
     } 
    } 

为此你所需要的仅仅是一个Map<String, ?>这充分反映了HTTP形式。

Multipart Http Sample也可以帮助你。