在Custom Mediator,WSO2 ESB中添加对SOAP消息的附件

时间:2017-07-19 16:39:53

标签: java soap wso2esb synapse

我正在尝试在WSO2 ESB中实现自定义中介,我想要实现的是中介必须将文件路径作为输入,然后将其作为附件添加到SOAP消息中。

到目前为止我编写的中介代码获取附件路径并打印SOAP消息。现在我已经浏览了MessageContext接口的文档,我可以看到我们可以在SOAP消息中添加/删除元素等,但我无法弄清楚如何在SOAP消息中添加附件。有什么想法吗?

import javax.activation.FileDataSource;
import org.apache.axiom.soap.SOAPBody;
import org.apache.synapse.MessageContext; 
import org.apache.synapse.mediators.AbstractMediator;

public class SoapModifier extends AbstractMediator { 

private String AttachmentFilePath;  

public boolean mediate(MessageContext context) { 
    context.setDoingSWA(true);
    FileDataSource fileDataSource = new FileDataSource(AttachmentFilePath);
    SOAPBody soapBody = context.getEnvelope().getBody();
    System.out.println("Message Being Processed : " + context.toString());
    return true;
}

public String getAttachmentFilePath(){
    return AttachmentFilePath;
}

public void setAttachmentFilePath(String path){
    AttachmentFilePath = path;
}
}

1 个答案:

答案 0 :(得分:0)

这可能会有所帮助 Attachments API in Apache Axis2

相关问题