热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javax.xml.soap.AttachmentPart.setContent()方法的使用及代码示例

本文整理了Java中javax.xml.soap.AttachmentPart.setContent()方法的一些代码示例,展示了AttachmentPar

本文整理了Java中javax.xml.soap.AttachmentPart.setContent()方法的一些代码示例,展示了AttachmentPart.setContent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttachmentPart.setContent()方法的具体详情如下:
包路径:javax.xml.soap.AttachmentPart
类名称:AttachmentPart
方法名:setContent

AttachmentPart.setContent介绍

[英]Sets the content of this attachment part to that of the given Object and sets the value of the Content-Type header to the given type. The type of the Object should correspond to the value given for the Content-Type. This depends on the particular set of DataContentHandler objects in use.
[中]将此附件部分的内容设置为给定Object的内容,并将Content-Type标头的值设置为给定类型。Object的类型应与Content-Type的给定值相对应。这取决于使用的DataContentHandler对象的特定集合。

代码示例

代码示例来源:origin: stackoverflow.com

AttachmentPart attachment = message.createAttachmentPart();
String stringCOntent= "Update address for Sunny Skies " +
"Inc., to 10 Upbeat Street, Pleasant Grove, CA 95439";
attachment.setContent(stringContent, "text/plain");
attachment.setContentId("update_address");
message.addAttachmentPart(attachment);

代码示例来源:origin: org.jboss.ws.native/jbossws-native-saaj

/**
* Creates an AttachmentPart object and populates it with the specified data of the specified content type.
* @param content an Object containing the content for this SOAPMessage object
* @param contentType a String object giving the type of content; examples are "text/xml", "text/plain", and "image/jpeg"
* @return a new AttachmentPart object that contains the given data
*/
public AttachmentPart createAttachmentPart(Object content, String contentType)
{
AttachmentPart part = createAttachmentPart();
part.setContent(content, contentType);
return part;
}

代码示例来源:origin: stackoverflow.com

throws SOAPException {
AttachmentPart attachment = soapMessage.createAttachmentPart();
attachment.setContent( new ByteArrayInputStream( theBytes ), contentType );
soapMessage.addAttachmentPart( attachment );

代码示例来源:origin: stackoverflow.com

byte[] encoded = Files.readAllBytes(Paths.get("C:\\Users\\timofb\\Documents\\test.txt"));
String soapXml = new String(encoded, StandardCharsets.UTF_8);
SOAPConnectionFactory soapCOnnectionFactory=
SOAPConnectionFactory.newInstance();
java.net.URL endpoint = new URL("http://" + ip + "/cs-repository/services/xds-iti41");
SOAPConnection cOnnection= soapConnectionFactory.createConnection();
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage(new MimeHeaders(), new ByteArrayInputStream(encoded));
AttachmentPart attachment = message.createAttachmentPart();
attachment.setContent("sm_content", "text/plain");
attachment.setContentId("1.9f910338bf0cac0e783bfdec7e53be9237684caa8f8f4e6d@apache.org");
message.addAttachmentPart(attachment);
SOAPMessage respOnse= connection.call(message, endpoint);
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.writeTo(out);
String strMsg = new String(out.toByteArray());
return strMsg;

代码示例来源:origin: org.apache.openejb/javaee-api

/**
* Creates an AttachmentPart object and populates it with the specified data of the
* specified content type.
*
* @param content an Object containing the content for this
* SOAPMessage object
* @param contentType a String object giving the type of content; examples are
* "text/xml", "text/plain", and "image/jpeg"
* @return a new AttachmentPart object that contains the given data
* @throws IllegalArgumentException
* if the contentType does not match the type of the content object, or if there was no
* DataContentHandler object for the given content object
* @see DataHandler DataHandler
* @see javax.activation.DataContentHandler DataContentHandler
*/
public AttachmentPart createAttachmentPart(Object content,
String contentType) {
AttachmentPart attachmentpart = createAttachmentPart();
attachmentpart.setContent(content, contentType);
return attachmentpart;
}

代码示例来源:origin: org.jboss.ws.native/jbossws-native-core

throw NativeMessages.MESSAGES.couldNotDetermineMimeType(partName);
part.setContent(value, mimeType);

代码示例来源:origin: javax.xml.soap/javax.xml.soap-api

/**
* Creates an {@code AttachmentPart} object and populates it with
* the specified data of the specified content type. The type of the
* {@code Object} should correspond to the value given for the
* {@code Content-Type}.
*
* @param content
* an {@code Object} containing the content for the
* {@code AttachmentPart} object to be created
* @param contentType
* a {@code String} object giving the type of content;
* examples are "text/xml", "text/plain", and "image/jpeg"
* @return a new {@code AttachmentPart} object that contains the
* given data
* @exception IllegalArgumentException
* may be thrown if the contentType does not match the type
* of the content object, or if there was no
* {@code DataContentHandler} object for the given
* content object
* @see javax.activation.DataHandler
* @see javax.activation.DataContentHandler
*/
public AttachmentPart createAttachmentPart(
Object content,
String contentType) {
AttachmentPart attachment = createAttachmentPart();
attachment.setContent(content, contentType);
return attachment;
}

代码示例来源:origin: javax/javaee-endorsed-api

/**
* Creates an AttachmentPart object and populates it with
* the specified data of the specified content type. The type of the
* Object should correspond to the value given for the
* Content-Type.
*
* @param content
* an Object containing the content for the
* AttachmentPart object to be created
* @param contentType
* a String object giving the type of content;
* examples are "text/xml", "text/plain", and "image/jpeg"
* @return a new AttachmentPart object that contains the
* given data
* @exception IllegalArgumentException
* may be thrown if the contentType does not match the type
* of the content object, or if there was no
* DataContentHandler object for the given
* content object
* @see javax.activation.DataHandler
* @see javax.activation.DataContentHandler
*/
public AttachmentPart createAttachmentPart(
Object content,
String contentType) {
AttachmentPart attachment = createAttachmentPart();
attachment.setContent(content, contentType);
return attachment;
}

代码示例来源:origin: jakarta.xml.soap/jakarta.xml.soap-api

/**
* Creates an {@code AttachmentPart} object and populates it with
* the specified data of the specified content type. The type of the
* {@code Object} should correspond to the value given for the
* {@code Content-Type}.
*
* @param content
* an {@code Object} containing the content for the
* {@code AttachmentPart} object to be created
* @param contentType
* a {@code String} object giving the type of content;
* examples are "text/xml", "text/plain", and "image/jpeg"
* @return a new {@code AttachmentPart} object that contains the
* given data
* @exception IllegalArgumentException
* may be thrown if the contentType does not match the type
* of the content object, or if there was no
* {@code DataContentHandler} object for the given
* content object
* @see javax.activation.DataHandler
* @see javax.activation.DataContentHandler
*/
public AttachmentPart createAttachmentPart(
Object content,
String contentType) {
AttachmentPart attachment = createAttachmentPart();
attachment.setContent(content, contentType);
return attachment;
}

代码示例来源:origin: org.jboss.spec.javax.xml.soap/jboss-saaj-api_1.3_spec

/**
* Creates an AttachmentPart object and populates it with
* the specified data of the specified content type. The type of the
* Object should correspond to the value given for the
* Content-Type.
*
* @param content
* an Object containing the content for the
* AttachmentPart object to be created
* @param contentType
* a String object giving the type of content;
* examples are "text/xml", "text/plain", and "image/jpeg"
* @return a new AttachmentPart object that contains the
* given data
* @exception IllegalArgumentException
* may be thrown if the contentType does not match the type
* of the content object, or if there was no
* DataContentHandler object for the given
* content object
* @see javax.activation.DataHandler
* @see javax.activation.DataContentHandler
*/
public AttachmentPart createAttachmentPart(
Object content,
String contentType) {
AttachmentPart attachment = createAttachmentPart();
attachment.setContent(content, contentType);
return attachment;
}

代码示例来源:origin: org.glassfish.metro/webservices-api-osgi

/**
* Creates an {@code AttachmentPart} object and populates it with
* the specified data of the specified content type. The type of the
* {@code Object} should correspond to the value given for the
* {@code Content-Type}.
*
* @param content
* an {@code Object} containing the content for the
* {@code AttachmentPart} object to be created
* @param contentType
* a {@code String} object giving the type of content;
* examples are "text/xml", "text/plain", and "image/jpeg"
* @return a new {@code AttachmentPart} object that contains the
* given data
* @exception IllegalArgumentException
* may be thrown if the contentType does not match the type
* of the content object, or if there was no
* {@code DataContentHandler} object for the given
* content object
* @see javax.activation.DataHandler
* @see javax.activation.DataContentHandler
*/
public AttachmentPart createAttachmentPart(
Object content,
String contentType) {
AttachmentPart attachment = createAttachmentPart();
attachment.setContent(content, contentType);
return attachment;
}

代码示例来源:origin: org.glassfish.metro/webservices-api

/**
* Creates an {@code AttachmentPart} object and populates it with
* the specified data of the specified content type. The type of the
* {@code Object} should correspond to the value given for the
* {@code Content-Type}.
*
* @param content
* an {@code Object} containing the content for the
* {@code AttachmentPart} object to be created
* @param contentType
* a {@code String} object giving the type of content;
* examples are "text/xml", "text/plain", and "image/jpeg"
* @return a new {@code AttachmentPart} object that contains the
* given data
* @exception IllegalArgumentException
* may be thrown if the contentType does not match the type
* of the content object, or if there was no
* {@code DataContentHandler} object for the given
* content object
* @see javax.activation.DataHandler
* @see javax.activation.DataContentHandler
*/
public AttachmentPart createAttachmentPart(
Object content,
String contentType) {
AttachmentPart attachment = createAttachmentPart();
attachment.setContent(content, contentType);
return attachment;
}

代码示例来源:origin: jboss/jboss-javaee-specs

/**
* Creates an AttachmentPart object and populates it with
* the specified data of the specified content type. The type of the
* Object should correspond to the value given for the
* Content-Type.
*
* @param content
* an Object containing the content for the
* AttachmentPart object to be created
* @param contentType
* a String object giving the type of content;
* examples are "text/xml", "text/plain", and "image/jpeg"
* @return a new AttachmentPart object that contains the
* given data
* @exception IllegalArgumentException
* may be thrown if the contentType does not match the type
* of the content object, or if there was no
* DataContentHandler object for the given
* content object
* @see javax.activation.DataHandler
* @see javax.activation.DataContentHandler
*/
public AttachmentPart createAttachmentPart(
Object content,
String contentType) {
AttachmentPart attachment = createAttachmentPart();
attachment.setContent(content, contentType);
return attachment;
}

代码示例来源:origin: apache/cxf

@Test
public void testSWA() throws Exception {
SOAPFactory soapFac = SOAPFactory.newInstance();
MessageFactory msgFac = MessageFactory.newInstance();
SOAPConnectionFactory cOnFac= SOAPConnectionFactory.newInstance();
SOAPMessage msg = msgFac.createMessage();
QName sayHi = new QName("http://apache.org/hello_world_rpclit", "sayHiWAttach");
msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
AttachmentPart ap1 = msg.createAttachmentPart();
ap1.setContent("Attachment content", "text/plain");
msg.addAttachmentPart(ap1);
AttachmentPart ap2 = msg.createAttachmentPart();
ap2.setContent("Attachment content - Part 2", "text/plain");
msg.addAttachmentPart(ap2);
msg.saveChanges();
SOAPConnection con = conFac.createConnection();
URL endpoint = new URL("http://localhost:" + PORT
+ "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1");
SOAPMessage respOnse= con.call(msg, endpoint);
QName sayHiResp = new QName("http://apache.org/hello_world_rpclit", "sayHiResponse");
assertNotNull(response.getSOAPBody().getChildElements(sayHiResp));
assertEquals(2, response.countAttachments());
}

推荐阅读
  • ***byte(字节)根据长度转成kb(千字节)和mb(兆字节)**parambytes*return*publicstaticStringbytes2kb(longbytes){ ... [详细]
  • 本文整理了Java面试中常见的问题及相关概念的解析,包括HashMap中为什么重写equals还要重写hashcode、map的分类和常见情况、final关键字的用法、Synchronized和lock的区别、volatile的介绍、Syncronized锁的作用、构造函数和构造函数重载的概念、方法覆盖和方法重载的区别、反射获取和设置对象私有字段的值的方法、通过反射创建对象的方式以及内部类的详解。 ... [详细]
  • HashMap的相关问题及其底层数据结构和操作流程
    本文介绍了关于HashMap的相关问题,包括其底层数据结构、JDK1.7和JDK1.8的差异、红黑树的使用、扩容和树化的条件、退化为链表的情况、索引的计算方法、hashcode和hash()方法的作用、数组容量的选择、Put方法的流程以及并发问题下的操作。文章还提到了扩容死链和数据错乱的问题,并探讨了key的设计要求。对于对Java面试中的HashMap问题感兴趣的读者,本文将为您提供一些有用的技术和经验。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Java中包装类的设计原因以及操作方法
    本文主要介绍了Java中设计包装类的原因以及操作方法。在Java中,除了对象类型,还有八大基本类型,为了将基本类型转换成对象,Java引入了包装类。文章通过介绍包装类的定义和实现,解答了为什么需要包装类的问题,并提供了简单易用的操作方法。通过本文的学习,读者可以更好地理解和应用Java中的包装类。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • 纠正网上的错误:自定义一个类叫java.lang.System/String的方法
    本文纠正了网上关于自定义一个类叫java.lang.System/String的错误答案,并详细解释了为什么这种方法是错误的。作者指出,虽然双亲委托机制确实可以阻止自定义的System类被加载,但通过自定义一个特殊的类加载器,可以绕过双亲委托机制,达到自定义System类的目的。作者呼吁读者对网上的内容持怀疑态度,并带着问题来阅读文章。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Java在运行已编译完成的类时,是通过java虚拟机来装载和执行的,java虚拟机通过操作系统命令JAVA_HOMEbinjava–option来启 ... [详细]
  • 重入锁(ReentrantLock)学习及实现原理
    本文介绍了重入锁(ReentrantLock)的学习及实现原理。在学习synchronized的基础上,重入锁提供了更多的灵活性和功能。文章详细介绍了重入锁的特性、使用方法和实现原理,并提供了类图和测试代码供读者参考。重入锁支持重入和公平与非公平两种实现方式,通过对比和分析,读者可以更好地理解和应用重入锁。 ... [详细]
author-avatar
mobiledu2502924307
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有