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