/** * Returns the first child element of the given body. */ public static SOAPElement getFirstBodyElement(SOAPBody body) { for (Iterator<?> iterator = body.getChildElements(); iterator.hasNext(); ) { Object child = iterator.next(); if (child instanceof SOAPElement) { return (SOAPElement) child; } } return null; }
/** * Returns the first child element of the given body. */ public static SOAPElement getFirstBodyElement(SOAPBody body) { for (Iterator<?> iterator = body.getChildElements(); iterator.hasNext(); ) { Object child = iterator.next(); if (child instanceof SOAPElement) { return (SOAPElement) child; } } return null; }
public static SOAPBodyElement getFirstSOAPBodyElement(final SOAPBody soapBody) { SOAPBodyElement bodyElement = null; final Iterator<?> it = soapBody.getChildElements(); while (bodyElement == null && it.hasNext()) { Object next = it.next(); if (next instanceof SOAPBodyElement) bodyElement = (SOAPBodyElement)next; } return bodyElement; }
@Override public SOAPElement getFirstBodyElement(SOAPBody body) { for (Iterator<?> iterator = body.getChildElements(); iterator.hasNext();) { Object child = iterator.next(); if (child instanceof SOAPElement) { return (SOAPElement) child; } } return null; }
/** * Returns the first child element of the given body. */ public static SOAPElement getFirstBodyElement(SOAPBody body) { for (Iterator<?> iterator = body.getChildElements(); iterator.hasNext(); ) { Object child = iterator.next(); if (child instanceof SOAPElement) { return (SOAPElement) child; } } return null; }
@Override public SOAPElement getFirstBodyElement(SOAPBody body) { for (Iterator<?> iterator = body.getChildElements(); iterator.hasNext();) { Object child = iterator.next(); if (child instanceof SOAPElement) { return (SOAPElement) child; } } return null; }
@Override public SOAPElement getFirstBodyElement(SOAPBody body) { for (Iterator<?> iterator = body.getChildElements(); iterator.hasNext();) { Object child = iterator.next(); if (child instanceof SOAPElement) { return (SOAPElement) child; } } return null; }
public static SOAPElement getSOAPBodyElement(SOAPEnvelope envelope) throws SOAPException { for (@SuppressWarnings("rawtypes") Iterator it = envelope.getBody().getChildElements(); it.hasNext();) { Object node = it.next(); if (node instanceof SOAPBodyElement) { return (SOAPElement) node; } } return null; } }
public static SOAPElement getSOAPBodyElement(SOAPEnvelope envelope) throws SOAPException { for (@SuppressWarnings("rawtypes") Iterator it = envelope.getBody().getChildElements(); it.hasNext();) { Object node = it.next(); if (node instanceof SOAPBodyElement) { return (SOAPElement) node; } } return null; } }
public boolean handleMessage(SoapMessageContext context){ ...... ...... SOAPBody soapbody=context.getMessage().getSOAPBody(); Iterator itr=soapbody.getChildElements(); while(itr.hasNext()){ SOAPElement se=(SOAPElement)itr.next(); System.out.println("Requsted class name "+se.getElementName().getLocalName()); } .... // proces the handler based on your class name }
SOAPMessage message = smc.getMessage(); SOAPBody body = message.getSOAPBody(); //Then grabbing the first child node of the body and checking its name: Iterator<Node> nodes = body.getChildElements(); // get the first one if (n.getNodeName().equals("The node name for the particular operation")) { // then we have it }
@Override public boolean handleMessage(SOAPMessageContext context) { SOAPBody body = context.getMessage().getSOAPPart().getEnvelope().getBody(); //do recursivelly, this is just example Iterator iter = body.getChildElements(); while (iter.hasNext()) { Object object = iter.next(); if (object instanceof SOAPElement) { SOAPElement element = (SOAPElement) object; if("urn:myns/b".equals(element.getNamespaceURI())){ element.setPrefix(""); } } }
private void writeEchoResponse(SOAPMessage message) throws SOAPException { SOAPEnvelope envelope = message.getSOAPPart().getEnvelope(); Name echoResponseName = envelope.createName("echoResponse", PREFIX, NAMESPACE_URI); SOAPBodyElement echoResponseElement = (SOAPBodyElement) message .getSOAPBody().getChildElements(echoResponseName).next(); String echoValue = echoResponseElement.getTextContent(); System.out.println(); System.out.println("Echo Response [" + echoValue + "]"); System.out.println(); }
public static boolean runFilterOnMessage(SOAPMessage msg, FilterType filter) { try { Iterator<?> i = msg.getSOAPBody().getChildElements(); final String xPath = (String)filter.getContent().get(0); while (i.hasNext()) { Element elm = (Element)i.next(); if (FilteringUtil.doesConformToFilter(elm, filter)) { LOG.info("Message passed through filter: " + xPath); } else { LOG.info("Filter " + xPath + " filtered out this message."); return false; } } return true; } catch (SOAPException e) { LOG.severe("SOAPException in runFilterOnMessage: " + e.toString()); return false; } } }
public ArrayList getMessageInfo(SOAPMessage message) { ArrayList list = new ArrayList(); try { if(message == null || message.getSOAPPart() == null) return list; SOAPEnvelope env = message.getSOAPPart().getEnvelope(); SOAPBody body = env.getBody(); Iterator it = body.getChildElements(); SOAPElement operation = (SOAPElement)it.next(); list.add(operation.getElementName().toString()); for (Iterator i = operation.getChildElements(); i.hasNext();) { SOAPElement elt = (SOAPElement)i.next(); list.add(elt.getElementName().toString()); } } catch (Exception e) { log.debug("Exception in getMessageInfo : ", e); } return list; }
public MessageSnapshot(final MessageContext soapMessage) { final SOAPMessage message = ((SOAPMessageContext) soapMessage).getMessage(); if (message == null || message.getSOAPPart() == null) { operationName = null; parameterNames = null; } else { final SOAPBody body = getBody(message); final SOAPElement operation = ((SOAPElement) body.getChildElements().next()); this.operationName = operation.getElementName().toString(); this.parameterNames = new ArrayList<String>(); for (final Iterator i = operation.getChildElements(); i.hasNext(); ) { final SOAPElement parameter = (SOAPElement) i.next(); final String element = parameter.getElementName().toString(); parameterNames.add(element); } } }
public ArrayList getMessageInfo(SOAPMessage message) { ArrayList list = new ArrayList(); try { if(message == null || message.getSOAPPart() == null) return list; SOAPEnvelope env = message.getSOAPPart().getEnvelope(); SOAPBody body = env.getBody(); Iterator it = body.getChildElements(); SOAPElement operation = (SOAPElement)it.next(); list.add(operation.getElementName().toString()); for (Iterator i = operation.getChildElements(); i.hasNext();) { SOAPElement elt = (SOAPElement)i.next(); list.add(elt.getElementName().toString()); } } catch (Exception e) { log.debug("Exception in getMessageInfo : ", e); } return list; }
public ArrayList getMessageInfo(SOAPMessage message) { ArrayList list = new ArrayList(); try { if(message == null || message.getSOAPPart() == null) return list; SOAPEnvelope env = message.getSOAPPart().getEnvelope(); SOAPBody body = env.getBody(); Iterator it = body.getChildElements(); SOAPElement operation = (SOAPElement)it.next(); list.add(operation.getElementName().toString()); for (Iterator i = operation.getChildElements(); i.hasNext();) { SOAPElement elt = (SOAPElement)i.next(); list.add(elt.getElementName().toString()); } } catch (Exception e) { log.debug("Exception in getMessageInfo : ", e); } return list; }
private Iterator<?> getBodyChildren(SOAPMessageContext context) { try { SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope(); SOAPBody body = envelope.getBody(); return body.getChildElements(); } catch (SOAPException e) { throw new IllegalStateException(e); } }
@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()); }