java - 附件部分 : how to get the name?

标签 java soap

我有一个调用 SOAP 网络服务的代码,该服务有一个附件(或多个附件),该附件是一个zip文件(或多个附件)。我只想要其中一些 zip 文件,即以“WCT_”开头的文件。

给定 AttachmentPart 变量是否有可能获取文件名?

Iterator<?> i = soapResponse.getAttachments();
Object obj = null;
while (i.hasNext()) {
    System.out.println("file found");
    AttachmentPart att = (AttachmentPart) i.next();

我尝试了 att.getContent().toString() 但没有打印名称。

最佳答案

尝试使用

Iterator<?> i = soapResponse.getAttachments();
Object obj = null;
while (i.hasNext()) {
    System.out.println("file found");
    AttachmentPart att = (AttachmentPart) i.next();
    String fileName = att.getDataHandler().getName();
}

关于java - 附件部分 : how to get the name?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57314386/

相关文章:

java - 如何在 Java 中并发处理 Collection 中的元素

java - 运行时动态 Web 服务调用

java - 意外的时区错误

java - 如何在 Jasper Server 5.6 中启用日志记录?

Java 编译带有 spring "Validator"类的警告

android - 如何在android中使用kso​​ap2库解析复杂的响应

java - org.ksoap2.serialization.SoapObject 无法转换为 org.ksoap2.serialization.SoapPrimitive

web-services - 如何更改 SOAP UI 5.2.1 中的身份验证类型?

java - 将 JAXB 元素编码为 SOAP 处理转义字符

java - Atlassian ui 单选未在速度模板中呈现