![](/img/trans.png)
[英]Multiple WebServiceTemplate and SaajSoapMessageFactory performance
[英]Is SaajSoapMessageFactory support Mtom resonse in Client side
我正在編寫一個Spring Webservice Client,它調用SOAP服務,它返回帶有附件的SOAP響應(Response中的MTOM-> XOP include標簽)。
在我當前的客戶端代碼中,我正在使用SaajSoapMessageFactory,並將其注入到WebServiceTemplate中,並且在編組器中將MtomEnabled設置為true。
通過此設置,當我調用SOAP服務時,我的客戶端代碼可以讀取SOAP響應正文,但是Response正文中的附件部分為空。 對於SOAP UI中的相同請求,我可以獲取附件。
客戶端中的SaajSoapMessageFactory是否支持MTOM響應?
我已經用SaajSoapMessageFactory提取附件
@SuppressWarnings("rawtypes")
public class MtomContentRespExtractor implements WebServiceMessageExtractor {
private static final Logger logger = LoggerFactory.getLogger(MtomContentRespExtractor.class);
private JAXBContext jaxbContext = null;
private Class<MyContentResponse> responseType;
public MtomContentRespExtractor(JAXBContext jaxbContext,
Class<MyContentResponse> responseType) {
this.jaxbContext = jaxbContext;
this.responseType = responseType;
}
@Override
public Object extractData(WebServiceMessage webServiceMsg) throws IOException, TransformerException {
JAXBElement<MyContentResponse> jaxbElement = null;
MyContentResponse myContResp = null;
try {
jaxbElement = jaxbContext.createUnmarshaller()
.unmarshal(webServiceMsg.getPayloadSource(), responseType);
Attachment attachment = (Attachment) ((SaajSoapMessage) webServiceMsg).getAttachments().next();
myContResp = (MyContentResponse) jaxbElement.getValue();
attachment.getInputStream()
//Logic for response
} catch (JAXBException e) {
logger.error(e.getMessage());
}
return myContResp;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.