0

I'm trying to make use of @attachment http properties

I have a devkit method called validate in a flow that is called like so

<http:connector name="httpConnector" doc:name="HTTP\HTTPS">
    <service-overrides
        messageFactory="org.mule.transport.http.HttpMultipartMuleMessageFactory" />
</http:connector>
<flow name="AttachmentTestFlow1" doc:name="AttachmentTestFlow1">        
    <http:inbound-endpoint connector-ref="httpConnector" doc:name="HTTP" exchange-pattern="request-response" host="localhost" port="8100"/>
    <Foo:validate config-ref="TestMessageSizeHappy"  />
</flow>

In Devkit:

@Processor
public Object validate(@Payload InputStream in
    ,@InboundAttachments("*") Map<String, DataHandler> inboundAttachments
    ,@OutboundAttachments Map<String, DataHandler> outboundAttachments
    ) {

however when running my mule application this is thrown:

ERROR 2013-07-30 09:06:39,225 [main] org.mule.module.launcher.application.DefaultMuleApplication: null org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of element 'xmlthreatprotection:validate' is not complete. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/xmlthreatprotection":inbound-attachments}' is expected. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

It seems to me that mule expects the attachments to be put in as an attribute some how ! When I remove the @attachment stuff I get no errors at runtime.

David Dossot
  • 33,403
  • 4
  • 38
  • 72
Nikos
  • 7,295
  • 7
  • 52
  • 88

1 Answers1

1

Are you sure this is supported by DevKit? I can not find a single integration test in the source code that exercises @InboundAttachments and @OutboundAttachments annotations, while @InboundHeaders and @OutboundHeaders are both test covered.

Alternatively you can receive the MuleEvent and access the attachments through it:

@Processor
@Inject
public Object validate(@Payload InputStream in, MuleEvent muleEvent) {
David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • I've tried it in 3.0.0 and it throws an exception and 3.2. and 3.4 it doesn't even compile, we found that you could get multipart attachements only working with very specific inbound implementation details – Nikos Jul 30 '13 at 20:51
  • So I don't think that its supported, its probably an extra annotation from my IDE. I might play with the @headers you mentioned! – Nikos Jul 30 '13 at 20:55
  • Do you prefer the @InboundHeaders and OutboundHeaders or the MuleEvent? – Nikos Aug 07 '13 at 08:23
  • its kind of funny how you have to add **muleEvent-ref="foo"** to your flow to get the MuleEvent to work, and devkit 3.4.0 to compile – Nikos Aug 07 '13 at 09:51
  • I found it useful to use ** – Nikos Aug 07 '13 at 12:40
  • 1
    You do not need to add `muleEvent-ref` to your flow. Mule passes the `MuleEvent` to your method without it (if you have correctly add the `@Inject` annotation). – David Dossot Aug 08 '13 at 16:32