I just want to send attachments in the http:request. Hence I prepared the following flows.
<flow name="http-request-payload-multipart-preparator">
<http:listener config-ref="GlobalHTTPConnector" path="/requestmultipartprep" doc:name="HTTP"/>
<expression-component doc:name="Expression"><![CDATA[
ds = new org.mule.message.ds.StringDataSource('key1','value1','text/plain');
dh = new javax.activation.DataHandler(ds);
message.outboundAttachments['key1'] = dh;
ds = new org.mule.message.ds.StringDataSource('key2','value2','text/plain');
dh = new javax.activation.DataHandler(ds);
message.outboundAttachments['key2'] = dh;]]></expression-component>
<set-payload value="#[null]" />
<http:request config-ref="HTTP_Request_Configuration" path="/simplemultiparthandler" method="POST" doc:name="HTTP"/>
</flow>
<flow name="sile-multipart-handler">
<http:listener config-ref="GlobalHTTPConnector" path="/simplemultiparthandler" doc:name="HTTP"/>
<logger level="INFO" message="#[message.inboundAttachments.keySet().toString()]" />
<logger level="INFO" message="#[message.inboundAttachments.'key1'.dataSource.name]" doc:name="Payload Logger"/>
<logger level="INFO" message="#[message.inboundAttachments.'key1'.dataSource.content]" doc:name="Payload Logger"/>
<logger level="INFO" message="#[message.inboundAttachments.'key2'.dataSource.name]" doc:name="Payload Logger"/>
<logger level="INFO" message="#[message.inboundAttachments.'key2'.dataSource.content]" doc:name="Payload Logger"/>
<set-payload value="baba sai" />
</flow>
This is working fine in mule 3.7. Here I can see the I have two attachments with names 'key1' and 'key2' respectively. But if I do the same thing in mule 3.5 with http:outbound-endpoint I am unable to get the keys. It is showing attachments names are 'value1' and 'value2' respectively.
Why is it behaving this way?
To get this done I changed the code as follows in 3.5. I exchanged the key and value names.
<flow name="http-request-payload-multipart-preparator">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" path="requestmultipart" connector-ref="NoSessionEncodingConnector" doc:name="HTTP" />
<expression-component doc:name="Expression"><![CDATA[
ds = new org.mule.message.ds.StringDataSource('value1','key1','text/plain');
dh = new javax.activation.DataHandler(ds);
message.outboundAttachments['key1'] = dh;
ds = new org.mule.message.ds.StringDataSource('value2','key2','text/plain');
dh = new javax.activation.DataHandler(ds);
message.outboundAttachments['key2'] = dh;
payload;]]></expression-component>
<set-payload value="#[null]" />
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" method="POST" doc:name="HTTP" path="simplemultiparthandler" connector-ref="NoSessionEncodingConnector" />
</flow>
<flow name="sile-multipart-handler">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" path="simplemultiparthandler" connector-ref="NoSessionEncodingConnector" doc:name="HTTP" />
<logger level="INFO" message="#[message.inboundAttachments.keySet().toString()]" />
<logger level="INFO" message="#[message.inboundAttachments.'key1'.dataSource.name]" doc:name="Payload Logger"/>
<logger level="INFO" message="#[message.inboundAttachments.'key1'.dataSource.inputStream]" doc:name="Payload Logger"/>
<logger level="INFO" message="#[message.inboundAttachments.'key2'.dataSource.name]" doc:name="Payload Logger"/>
<logger level="INFO" message="#[message.inboundAttachments.'key2'.dataSource.inputStream]" doc:name="Payload Logger"/>
</flow>
Why is this difference in 3.5 and 3.7?