當前位置: 首頁>>代碼示例>>Java>>正文


Java SOAPMessage.countAttachments方法代碼示例

本文整理匯總了Java中javax.xml.soap.SOAPMessage.countAttachments方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPMessage.countAttachments方法的具體用法?Java SOAPMessage.countAttachments怎麽用?Java SOAPMessage.countAttachments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.soap.SOAPMessage的用法示例。


在下文中一共展示了SOAPMessage.countAttachments方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAttachmentsInfo

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
/**
 * Returns a string containing info about all the SOAP attachments.
 *
 * @param soapMessage SOAP message
 * @return String containing attachments info
 */
public static String getAttachmentsInfo(SOAPMessage soapMessage) {
    try {
        int numOfAttachments = soapMessage.countAttachments();
        Iterator attachments = soapMessage.getAttachments();

        StringBuilder buf = new StringBuilder("Number of attachments: ");
        buf.append(numOfAttachments);
        int count = 1;
        while (attachments.hasNext()) {
            AttachmentPart attachment = (AttachmentPart) attachments.next();
            buf.append(" | #").append(count);
            buf.append(" | Content Location: ").append(attachment.getContentLocation());
            buf.append(" | Content Id: ").append(attachment.getContentId());
            buf.append(" | Content Size: ").append(attachment.getSize());
            buf.append(" | Content Type: ").append(attachment.getContentType());
            count++;
        }
        return buf.toString();
    } catch (SOAPException e) {
        LOGGER.error(e.getMessage(), e);
        return "";
    }
}
 
開發者ID:vrk-kpa,項目名稱:xrd4j,代碼行數:30,代碼來源:AdapterUtils.java

示例2: getAttachmentContentType

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
/**
 * Returns the content type of the first SOAP attachment or null if there's
 * no attachments.
 *
 * @param message SOAP message
 * @return content type of the first attachment or null
 */
public static String getAttachmentContentType(SOAPMessage message) {
    if (message.countAttachments() == 0) {
        return null;
    }
    AttachmentPart att = (AttachmentPart) message.getAttachments().next();
    return att.getContentType();

}
 
開發者ID:vrk-kpa,項目名稱:xrd4j,代碼行數:16,代碼來源:SOAPHelper.java

示例3: hasAttachments

import javax.xml.soap.SOAPMessage; //導入方法依賴的package包/類
/**
 * Checks if the given SOAP message has attachments. Returns true if and
 * only if the message has attachments. Otherwise returns false.
 *
 * @param message SOAP message to be checked
 * @return true if and only if the message has attachments; otherwise false
 */
public static boolean hasAttachments(SOAPMessage message) {
    if (message == null) {
        return false;
    }
    if (message.countAttachments() == 0) {
        return false;
    }
    return true;
}
 
開發者ID:vrk-kpa,項目名稱:xrd4j,代碼行數:17,代碼來源:SOAPHelper.java


注:本文中的javax.xml.soap.SOAPMessage.countAttachments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。