1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.ws.security.common;
21
22 import javax.xml.parsers.DocumentBuilder;
23 import javax.xml.parsers.DocumentBuilderFactory;
24
25 import java.io.ByteArrayInputStream;
26 import java.io.InputStream;
27
28 public class SOAPUtil {
29
30 public static final String SAMPLE_SOAP_MSG =
31 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
32 + "<SOAP-ENV:Envelope "
33 + "xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
34 + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
35 + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
36 + "<SOAP-ENV:Body>"
37 + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
38 + "<value xmlns=\"\">15</value>"
39 + "</add>"
40 + "</SOAP-ENV:Body>"
41 + "</SOAP-ENV:Envelope>";
42
43 private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
44
45 static {
46 factory.setNamespaceAware(true);
47 }
48
49
50
51
52 public static org.w3c.dom.Document toSOAPPart(String xml) throws Exception {
53 InputStream in = new ByteArrayInputStream(xml.getBytes());
54 DocumentBuilder builder = factory.newDocumentBuilder();
55 return builder.parse(in);
56 }
57
58 }