Spring integration 使用http入站网关读取mtom消息
下面的示例中,我尝试构建一个示例来接收内容类型为multipart/related的mtom消息,但没有成功 您知道spring集成是否支持接收多部分/相关内容类型吗 谢谢你的帮助 以下是我的xml:Spring integration 使用http入站网关读取mtom消息,spring-integration,Spring Integration,下面的示例中,我尝试构建一个示例来接收内容类型为multipart/related的mtom消息,但没有成功 您知道spring集成是否支持接收多部分/相关内容类型吗 谢谢你的帮助 以下是我的xml: <int-http:inbound-gateway request-channel="channel" path="/services/mtom" supported-methods="POST" reply-channel="response" reque
<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"
POSThttp://localhost:8080/http-多部分示例/服务/mtom HTTP/1.1
接受编码:gzip,deflate
内容类型:多部分/相关;type=“应用程序/xop+xml”;start=“”;start info=“text/xml”;boundary=“---=\u Part\u 28\u 207620374.149920711379”
SOAPAction:“
MIME版本:1.0
------=_零件_28_207620374.149920711379
内容类型:应用程序/xop+xml;字符集=UTF-8;type=“text/xml”
内容传输编码:8比特
内容ID:
1994-11-05T08:15:30-05:00
1.
2.
1111
------=_零件_28_207620374.149920711379
内容类型:应用程序/八位字节流;name=soapui-5.1.3.jar
内容传输编码:二进制
内容ID:
内容处置:附件;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>
multiparthttp
多部分
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/servlet-config.xml
1.
/home/tom/tmp
1000000000
1000000000
1048576
多部分
/*
编辑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}]
public void receive(Message Message)抛出MessaginException、IOException{
logger.info(“已成功接收到请求消息”);
}
已成功接收多部分请求:GenericMessage[payload=byte[0],Header={content length=11634876,http_requestMethod=POST,host=localhost:8080,http_requestUrl=http://localhost:8080/http-多部分示例/服务/mtom,内容类型=多部分/相关;type=“应用程序/xop+xml”start=“”;start info=“文本/xml”边界=“---=_Part_73_763506982.149934871151”,connection=Keep-Alive,id=3a74250d-db39-6b87-200e-7b79071590b2,accept-encoding=gzip,deflate,user-agent=Apache-HttpClient/4.1.1(java 1.5),timestamp=1499348713970}]
新的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 {
}
公共类MTOMHttpMessageConverter扩展了AbstractHttpMessageConverter{
@凌驾
公共布尔值可以读取(java.lang.Class clazz,org.springframework.http.MediaType-MediaType){
返回true;
};
@凌驾
受保护对象readInternal(类clazz,HttpInputMessage inputMessage)
抛出IOException、HttpMessageNodeReadableException{
}
为什么不在这个问题上使用WS-Inbound Gateway?因为它是一个接受基本soap消息和mtom消息的通用http端点。该端点接收消息,然后使用WS-addressing Header将其路由到相应的WS-services。恐怕您必须在mat上修改自己的自定义HttpMessageConverter
当然,如果您需要内容。如果您只需要原始数据,您可以期望请求有效负载type=“byte[]"并使用ws-addressing header将其路由到相应的ws-services。谢谢Artem!我尝试制作自己的HMC,但没有在httpServletRequest上注入任何部分。有什么想法吗?我用我的web.xml进行了更新。我使用的是Tomcat 7抱歉,我必须说,在DefaultMultipartTtpServletRequest上没有注入任何部分。另一方面,我开发了一个基本的Servlet基于MIMUMultipart,运行良好,但我希望在SI上实现,有什么想法吗?