SOAPHeader header = sourceEnv.getHeader();
String encoding = "UTF-8";
// Create a header OMSE
String hdrText = "<hdr:myheader xmlns:hdr=\"urn://test\">Hello World</hdr:myheader>";
ByteArrayDataSource badsHdr =
new ByteArrayDataSource(hdrText.getBytes(encoding), encoding);
OMNamespace hdrNS = header.getOMFactory().createOMNamespace("urn://test", "hdr");
SOAPFactory sf = (SOAPFactory) header.getOMFactory();
SOAPHeaderBlock shb = sf.createSOAPHeaderBlock("myheader", hdrNS, badsHdr);
shb.setProcessed(); // test setting processing flag
header.addChild(shb);
// Create a payload
String text = "<tns:payload xmlns:tns=\"urn://test\">Hello World</tns:payload>";
ByteArrayDataSource bads = new ByteArrayDataSource(text.getBytes(encoding), encoding);
OMNamespace ns = body.getOMFactory().createOMNamespace("urn://test", "tns");
OMSourcedElement omse =body.getOMFactory().createOMElement(bads, "payload", ns);
body.addChild(omse);
copyAndCheck(sourceEnv, true);