根据这些示例,我尝试构建一个示例,以接收带有multipart / related作为内容类型的mtom消息,但没有成功。
是否有任何想法Spring-integration是否支持将multipart / related作为内容类型接收?
感谢任何帮助
这是我的xml:
<int-http:inbound-gateway request-channel="channel"
path="/services/mtom" supported-methods="POST" reply-channel="response"
request-payload-type="java.lang.String"
message-converters="messageConverters">
</int-http:inbound-gateway>
<util:list id="messageConverters">
<bean class="org.springframework.integration.http.converter.MultipartAwareFormHttpMessageConverter"/>
</util:list>
这是我发送的消息
POST http://localhost:8080/http-multipart-sample/services/mtom HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: multipart/related; type="application/xop+xml"; start="<rootpart@soapui.org>"; start-info="text/xml"; boundary="----=_Part_28_207620374.1499207113979"
SOAPAction: ""
MIME-Version: 1.0
------=_Part_28_207620374.1499207113979
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <rootpart@soapui.org>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.redstrawberry.middleware.fing.edu/">
<soapenv:Header/>
<soapenv:Body>
<ws:receiveOrder>
<!--Optional:-->
<order>
<!--Optional:-->
<imageData><inc:Include href="cid:463691671957" xmlns:inc="http://www.w3.org/2004/08/xop/include"/></imageData>
<!--Optional:-->
<dateTime>1994-11-05T08:15:30-05:00</dateTime>
<productId>1</productId>
<quantity>2</quantity>
<!--Optional:-->
<transactionId>1111</transactionId>
</order>
</ws:receiveOrder>
</soapenv:Body>
</soapenv:Envelope>
------=_Part_28_207620374.1499207113979
Content-Type: application/octet-stream; name=soapui-5.1.3.jar
Content-Transfer-Encoding: binary
Content-ID: <soapui-5.1.3.jar>
Content-Disposition: attachment; name="soapui-5.1.3.jar"; filename="soapui-5.1.3.jar"
编辑:
的web.xml:
<display-name>multipart-http</display-name>
<servlet>
<servlet-name>Multipart</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/servlet-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<multipart-config>
<location>/home/tom/tmp</location>
<max-file-size>1000000000</max-file-size>
<max-request-size>1000000000</max-request-size>
<file-size-threshold>1048576</file-size-threshold>
</multipart-config>
</servlet>
<servlet-mapping>
<servlet-name>Multipart</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
编辑2:
public void receive(Message message ) throws MessagingException, IOException{
logger.info("###############################\nSuccessfully received multipart request: " + message);
}
Successfully received multipart request: GenericMessage [payload=byte[0], headers={content-length=11634876, http_requestMethod=POST, host=localhost:8080, http_requestUrl=http://localhost:8080/http-multipart-sample/services/mtom, content-type=multipart/related;type="application/xop+xml";start="<rootpart@soapui.org>";start-info="text/xml";boundary="----=_Part_73_763506982.1499348711151", connection=Keep-Alive, id=3a74250d-db39-6b87-200e-7b79071590b2, accept-encoding=gzip,deflate, user-agent=Apache-HttpClient/4.1.1 (java 1.5), timestamp=1499348723970}]
新SI配置:
<int-http:inbound-channel-adapter channel="channel"
path="/services/mtom" supported-methods="POST" message-converters="messageConverters">
</int-http:inbound-channel-adapter>
<util:list id="messageConverters">
<bean class="sample.MTOMHttpMessageConverter"/>
</util:list>
<int:channel id="channel"/>
<int:service-activator input-channel="channel" >
<bean class="sample.MultipartReceiver"/>
</int:service-activator>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
public class MTOMHttpMessageConverter<T> extends AbstractHttpMessageConverter<Object>{
@Override
public boolean canRead(java.lang.Class<?> clazz, org.springframework.http.MediaType mediaType) {
return true;
};
@Override
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage)
throws IOException, HttpMessageNotReadableException {
}