簡體   English   中英

在自定義介體,WSO2 ESB中向SOAP消息添加附件

[英]Add attachment to SOAP message in Custom Mediator, WSO2 ESB

我正在嘗試在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;
}
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM