/** * Get the text content of a node and all it's children or null if there is no text */ public static String getAllContent(Node n) { StringBuilder b = new StringBuilder(); getAllContent(n, b); return b.toString(); } private static void getAllContent(Node n, StringBuilder b) {
/** * Get the text content of a node and all it's children or null if there is no text */ public static String getAllContent(Node n) { StringBuilder b = new StringBuilder(); getAllContent(n, b); return b.toString(); } private static void getAllContent(Node n, StringBuilder b) {
/** * Get the text content of a node and all it's children or null if there is no text */ public static String getAllContent(Node n) { StringBuilder b = new StringBuilder(); getAllContent(n, b); return b.toString(); } private static void getAllContent(Node n, StringBuilder b) {
/** * Get the text content of a node and all it's children or null if there is no text */ public static String getAllContent(Node n) { StringBuilder b = new StringBuilder(); getAllContent(n, b); return b.toString(); } private static void getAllContent(Node n, StringBuilder b) {
private static void getAllContent(Node n, StringBuilder b) { Node nd = n.getFirstChild(); while (nd != null) { if (nd instanceof Text && !(nd instanceof Comment)) { b.append(((Text)nd).getData()); } else { getAllContent(nd, b); } nd = nd.getNextSibling(); } } /**
private static void getAllContent(Node n, StringBuilder b) { Node nd = n.getFirstChild(); while (nd != null) { if (nd instanceof Text && !(nd instanceof Comment)) { b.append(((Text)nd).getData()); } else { getAllContent(nd, b); } nd = nd.getNextSibling(); } } /**
private static void getAllContent(Node n, StringBuilder b) { Node nd = n.getFirstChild(); while (nd != null) { if (nd instanceof Text && !(nd instanceof Comment)) { b.append(((Text)nd).getData()); } else { getAllContent(nd, b); } nd = nd.getNextSibling(); } } /**
private static void getAllContent(Node n, StringBuilder b) { Node nd = n.getFirstChild(); while (nd != null) { if (nd instanceof Text && !(nd instanceof Comment)) { b.append(((Text)nd).getData()); } else { getAllContent(nd, b); } nd = nd.getNextSibling(); } } /**
DOMUtils.getAllContent(frag)); } else { writer.writeAttribute(fname.getLocalPart(), DOMUtils.getAllContent(frag)); if (attNs != null) { writer.writeAttribute(attNs, mname.getLocalPart(), DOMUtils.getAllContent(frag)); } else { writer.writeAttribute(mname.getLocalPart(), DOMUtils.getAllContent(frag));
@Test public void testCreateDispatchWithEPR() throws Exception { URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl"); assertNotNull(wsdl); SOAPService service = new SOAPService(wsdl, SERVICE_NAME); assertNotNull(service); W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder(); builder.address("http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort"); builder.serviceName(SERVICE_NAME); builder.endpointName(PORT_NAME); W3CEndpointReference w3cEpr = builder.build(); Dispatch<SOAPMessage> disp = service .createDispatch(w3cEpr, SOAPMessage.class, Service.Mode.MESSAGE); InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml"); SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, is); assertNotNull(soapReqMsg); SOAPMessage soapResMsg = disp.invoke(soapReqMsg); assertNotNull(soapResMsg); String expected = "Hello TestSOAPInputMessage"; assertEquals("Response should be : Hello TestSOAPInputMessage", expected, DOMUtils.getAllContent(SAAJUtils.getBody(soapResMsg)).trim()); }
DOMUtils.getAllContent(domResMsg.getNode().getFirstChild()).trim());