我正在尝试将带有文件和两个输入的表单发送到 Mule 入站端点。我有一个自定义处理器,以及这样定义的流程:
<custom-processor class="informa.app.classifier.transformers.MyfileUploadProcessor" name="fileuploadprocessor"></custom-processor>
<flow name="httpTest">
<http:inbound-endpoint
address="http://tango.privada.informa:11002/services/fileupload"></http:inbound-endpoint>
<processor ref="fileuploadprocessor"/>
</flow>
在 MyfileUploadProcessor 类中:
公共类 MyfileUploadProcessor 实现 MessageProcessor {
@Override
public MuleEvent process(MuleEvent event) throws MuleException {
// TODO Auto-generated method stub
String response = "success";
MuleMessage mulemessage = event.getMessage();
String countryCode = mulemessage.getInboundProperty("username");
String sourceCode = mulemessage.getInboundProperty("password");
InputStream input = (InputStream) mulemessage.getPayload();
...
为了测试,一个简单的html:
<form action="http://tango.privada.informa:11002/services/fileupload" method="post"
enctype="multipart/form-data">
<p>Country Code :<input type="text" name="username" /></p>
<p>Source Code :<input type="text" name="password" /></p>
<p>File :<input type="file" name="payload" /></p>
<p><input type="submit" name="submit" value="submit" />
<input type="reset" name="reset" value="reset"></p>
</form>
</body>
</html>
问题是我无法从 mulemessage 的有效负载创建文件,而且我不知道如何获取表单中输入的值......我做错了什么?任何线索?
提前致谢