jeudi 16 avril 2015

MuleClient does not seem to be properly attaching files

I am trying to test a flow using MuleClient, and I cannot seem to attach a file properly, here is the Munit code:



MuleClient client = new MuleClient(muleContext);
DefaultMuleMessage message = new DefaultMuleMessage("mulesslendpointbugtestFlow", muleContext);

message.setOutboundProperty("Content-type", "text/mutipart-formdata");
message.setOutboundProperty("Accept", "text/plain");
message.setOutboundProperty("http.method", "POST");

byte[] data = IOUtils.toByteArray(this.getClass().getClassLoader().getResourceAsStream("exportFile7612370654182310210.csv"));

List<Part> parts = Arrays.<Part>asList(
new HttpPart("exportFile", data, "text/csv", data.length));
Map<String, DataHandler> dataHandlers =
HttpPartDataSource.createDataHandlerFrom(parts);
for (Map.Entry<String, DataHandler> entry : dataHandlers.entrySet()) {
System.out.println("entry:"+entry.getKey());
message.addOutboundAttachment(entry.getKey(), entry.getValue());
}

MuleMessage result=client.send("http://localhost:8888/test", message);


Here is the configuration XML:




.....


The problem I am getting is that the message.inboundAttachments.'exportFile'.dataSource.content is causing a NullPointerException. What am I missing here? I am running Mule 3.6.1


Aucun commentaire:

Enregistrer un commentaire