Example usage for javax.xml.soap MimeHeaders setHeader

List of usage examples for javax.xml.soap MimeHeaders setHeader

Introduction

In this page you can find the example usage for javax.xml.soap MimeHeaders setHeader.

Prototype

public void setHeader(String name, String value) 

Source Link

Document

Replaces the current value of the first header entry whose name matches the given name with the given value, adding a new header if no existing header name matches.

Usage

From source file:test.saaj.TestAttachmentSerialization.java

public int loadMsgWithAttachments(InputStream is) throws Exception {
    MimeHeaders headers = new MimeHeaders();
    headers.setHeader("Content-Type", MIME_MULTIPART_RELATED);
    MessageFactory mf = MessageFactory.newInstance();
    SOAPMessage msg = mf.createMessage(headers, is);
    SOAPPart sp = msg.getSOAPPart();
    SOAPEnvelope envelope = sp.getEnvelope();
    assertTrue(sp != null);/*  ww  w.jav  a2 s.  c  o m*/
    assertTrue(envelope != null);
    return msg.countAttachments();
}