List of usage examples for javax.xml.soap SOAPBody getChildElements
public Iterator<Node> getChildElements();
From source file:com.polivoto.networking.SoapClient.java
public String start() throws SOAPException, IOException { String resp = "NaN"; // Create SOAP Connection SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); // Send SOAP Message to SOAP Server String url = "http://" + host + "/FistVotingServiceBank/services/ServAvailableVoteProcesses.ServAvailableVoteProcessesHttpSoap11Endpoint/"; SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url); SOAPBody body = soapResponse.getSOAPBody(); java.util.Iterator updates = body.getChildElements(); // El siguiente ciclo funciona slo porque el cuerpo contiene // un elemento y ste a suvez nicamente contiene un elemento. while (updates.hasNext()) { System.out.println();//from ww w . j a v a 2s.c o m // The listing and its ID SOAPElement update = (SOAPElement) updates.next(); java.util.Iterator i = update.getChildElements(); while (i.hasNext()) { SOAPElement e = (SOAPElement) i.next(); String name = e.getLocalName(); String value = e.getValue(); resp = value; // Am I getting last response? System.out.println(name + ": " + value); } } soapConnection.close(); return resp; }
From source file:edu.xtec.colex.client.beans.ColexIndexBean.java
/** * Returns a Vector containing the guest collections (Collection,Guest) * stored into SOAPMessage//from w w w . j a va 2s .co m * * @param sm the SOAPMessage * @throws javax.xml.soap.SOAPException when a SOAPException error occurs * @return the Vector */ protected Vector getListGuestCollections(SOAPMessage sm) throws SOAPException { Vector vRes = new Vector(); SOAPBody sb = sm.getSOAPBody(); Iterator it = sb.getChildElements(); Iterator it2 = null; SOAPElement se = (SOAPElement) it.next(); it = se.getChildElements(sf.createName("guestCollections")); se = (SOAPElement) it.next(); it = se.getChildElements(sf.createName("guestCollection")); while (it.hasNext()) { se = (SOAPElement) it.next(); it2 = se.getChildElements(sf.createName("collection")); Collection c = new Collection((SOAPElement) it2.next()); vRes.add(c); it2 = se.getChildElements(sf.createName("guest")); Guest g = new Guest((SOAPElement) it2.next()); vRes.add(g); } return vRes; }
From source file:com.inbravo.scribe.rest.service.crm.ms.auth.SOAPExecutor.java
/** * Constructs XPath query over the SOAP message * //from w ww . j a v a 2s .c o m * @param query XPath query * @param response SOAP message * @return XPath query * @throws SOAPException in case of SOAP issue * @throws JaxenException XPath problem */ public final XPath createXPath(final String query, final SOAPMessage response) throws SOAPException, JaxenException { /* Uses DOM to XPath mapping */ final XPath xpath = new DOMXPath(query); /* Define a namespaces used in response */ final SimpleNamespaceContext nsContext = new SimpleNamespaceContext(); final SOAPPart sp = response.getSOAPPart(); final SOAPEnvelope env = sp.getEnvelope(); final SOAPBody bdy = env.getBody(); /* Add namespaces from SOAP envelope */ addNamespaces(nsContext, env); /* Add namespaces of top body element */ final Iterator<?> bodyElements = bdy.getChildElements(); while (bodyElements.hasNext()) { SOAPElement element = (SOAPElement) bodyElements.next(); addNamespaces(nsContext, element); } xpath.setNamespaceContext(nsContext); return xpath; }
From source file:com.twinsoft.convertigo.engine.translators.WebServiceTranslator.java
public void buildInputDocument(Context context, Object inputData) throws Exception { Engine.logBeans.debug("[WebServiceTranslator] Making input document"); HttpServletRequest request = (HttpServletRequest) inputData; SOAPMessage requestMessage = (SOAPMessage) request .getAttribute(WebServiceServlet.REQUEST_MESSAGE_ATTRIBUTE); SOAPPart sp = requestMessage.getSOAPPart(); SOAPEnvelope se = sp.getEnvelope(); SOAPBody sb = se.getBody(); Iterator<?> iterator = sb.getChildElements(); SOAPElement method, parameter; String methodName;// w ww .j av a2 s .c o m InputDocumentBuilder inputDocumentBuilder = new InputDocumentBuilder(context); while (iterator.hasNext()) { List<RequestableVariable> variableList = null; // jmc 12/06/26 Object element = iterator.next(); if (element instanceof SOAPElement) { method = (SOAPElement) element; methodName = method.getElementName().getLocalName(); Engine.logBeans.debug("[WebServiceTranslator] Requested web service name: " + methodName); int i = methodName.indexOf("__"); // for statefull transaction, don't replace the project if (context.project == null || !context.project.getName().equals(context.projectName)) { context.project = Engine.theApp.databaseObjectsManager.getProjectByName(context.projectName); } String connectorName = null; if (i == -1) { context.connectorName = null; context.sequenceName = methodName; } else { connectorName = methodName.substring(0, i); context.transactionName = methodName.substring(i + 2); } if ((connectorName != null) && (!connectorName.equals(context.connectorName))) { Engine.logBeans.debug("Connector name differs from previous one; requiring new session"); context.isNewSession = true; context.connectorName = connectorName; Engine.logBeans.debug("[WebServiceTranslator] The connector is overridden to \"" + context.connectorName + "\"."); } Engine.logBeans.debug("[WebServiceTranslator] Connector: " + (context.connectorName == null ? "(default)" : context.connectorName)); Engine.logBeans.debug("[WebServiceTranslator] Transaction: " + context.transactionName); //Connector connector = (context.connectorName == null ? context.project.getDefaultConnector() : context.project.getConnectorByName(context.connectorName)); //Transaction transaction = (context.transactionName == null ? connector.getDefaultTransaction() : connector.getTransactionByName(context.transactionName)); RequestableObject requestable = null; if (context.sequenceName != null) { requestable = context.project.getSequenceByName(context.sequenceName); variableList = ((Sequence) requestable).getVariablesList(); } else if (context.connectorName != null) { if (context.transactionName != null) { requestable = context.project.getConnectorByName(context.connectorName) .getTransactionByName(context.transactionName); if (requestable instanceof TransactionWithVariables) { variableList = ((TransactionWithVariables) requestable).getVariablesList(); } } } Iterator<?> iterator2 = method.getChildElements(); String parameterName, parameterValue; while (iterator2.hasNext()) { element = iterator2.next(); if (element instanceof SOAPElement) { parameter = (SOAPElement) element; parameterName = parameter.getElementName().getLocalName(); parameterValue = parameter.getValue(); if (parameterValue == null) { parameterValue = ""; } if (variableList != null) { // jmc 12/06/26 hide hidden variables in sequences String str = (String) Visibility.Logs.replaceVariables(variableList, "" + parameterName + "=\"" + parameterValue + "\""); Engine.logBeans.debug(" Parameter: " + str); } else Engine.logBeans.debug(" Parameter: " + parameterName + "=\"" + parameterValue + "\""); // Handle convertigo parameters if (parameterName.startsWith("__")) { webServiceServletRequester.handleParameter(parameterName, parameterValue); } // Common parameter handling if (inputDocumentBuilder.handleSpecialParameter(parameterName, parameterValue)) { // handled } // Compatibility for Convertigo 2.x else if (parameterName.equals("context")) { // Just ignore it } else { SOAPElement soapArrayElement = null; Iterator<?> iterator3; String href = parameter.getAttributeValue(se.createName("href")); String arrayType = parameter.getAttributeValue(se.createName("soapenc:arrayType")); if (arrayType == null) { iterator3 = parameter.getAllAttributes(); while (iterator3.hasNext()) { element = iterator3.next(); if (element instanceof Name) { String s = ((Name) element).getQualifiedName(); if (s.equals("soapenc:arrayType")) { arrayType = s; break; } } } } // Array (Microsoft .net) if (href != null) { Engine.logBeans.debug("Deserializing Microsoft .net array"); iterator3 = sb.getChildElements(); while (iterator3.hasNext()) { element = iterator3.next(); if (element instanceof SOAPElement) { soapArrayElement = (SOAPElement) element; String elementId = soapArrayElement.getAttributeValue(se.createName("id")); if (elementId != null) { if (href.equals("#" + elementId)) { iterator3 = soapArrayElement.getChildElements(); while (iterator3.hasNext()) { element = iterator3.next(); if (element instanceof SOAPElement) { break; } } break; } } } } // Find the element with href id iterator3 = sb.getChildElements(); while (iterator3.hasNext()) { element = iterator3.next(); if (element instanceof SOAPElement) { soapArrayElement = (SOAPElement) element; String elementId = soapArrayElement.getAttributeValue(se.createName("id")); if (elementId != null) { if (href.equals("#" + elementId)) { break; } } } } } // Array (Java/Axis) else if (arrayType != null) { Engine.logBeans.debug("Deserializing Java/Axis array"); soapArrayElement = parameter; } // If the node has children nodes, we assume it is an array. else if (parameter.getChildElements().hasNext()) { if (isSoapArray((IVariableContainer) requestable, parameterName)) { Engine.logBeans.debug("Deserializing array"); soapArrayElement = parameter; } } // Deserializing array if (soapArrayElement != null) { iterator3 = soapArrayElement.getChildElements(); while (iterator3.hasNext()) { element = iterator3.next(); if (element instanceof SOAPElement) { soapArrayElement = (SOAPElement) element; parameterValue = soapArrayElement.getValue(); if (parameterValue == null) parameterValue = ""; handleSimpleVariable(context.inputDocument, soapArrayElement, parameterName, parameterValue, inputDocumentBuilder.transactionVariablesElement); } } } // Deserializing simple variable else { handleSimpleVariable(context.inputDocument, parameter, parameterName, parameterValue, inputDocumentBuilder.transactionVariablesElement); } } } } if (Engine.logBeans.isDebugEnabled()) { String soapMessage = SOAPUtils.toString(requestMessage, request.getCharacterEncoding()); if (requestable instanceof TransactionWithVariables) Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n" + Visibility.Logs.replaceVariables( ((TransactionWithVariables) (requestable)).getVariablesList(), request)); else if (requestable instanceof Sequence) Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n" + Visibility.Logs .replaceVariables(((Sequence) (requestable)).getVariablesList(), request)); else Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n" + soapMessage); } break; } } Engine.logBeans.debug("[WebServiceTranslator] SOAP message analyzed"); Engine.logBeans.debug("[WebServiceTranslator] Input document created"); }
From source file:com.centurylink.mdw.hub.servlet.SoapServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { CodeTimer timer = new CodeTimer("SoapServlet.doPost()", true); InputStream reqInputStream = request.getInputStream(); // read the POST request contents String requestString = getRequestString(request); if (logger.isMdwDebugEnabled()) { logger.mdwDebug("SOAP Listener POST Request:\n" + requestString); }//from w w w.j a v a2 s . c o m Map<String, String> metaInfo = buildMetaInfo(request); String responseString = null; MessageFactory factory = null; String soapVersion = SOAPConstants.SOAP_1_1_PROTOCOL; try { SOAPMessage message = null; SOAPBody body = null; try { // Intuitively guess which SOAP version is needed // factory = getMessageFactory(requestString, true); soapVersion = getSoapVersion(requestString, true); factory = getSoapMessageFactory(soapVersion); reqInputStream = new ByteArrayInputStream(requestString.getBytes()); message = factory.createMessage(null, reqInputStream); body = message.getSOAPBody(); } catch (SOAPException e) { // Unlikely, but just in case the SOAP version guessing // has guessed incorrectly, this catches any SOAP exception, // in which case try the other version if (logger.isMdwDebugEnabled()) { logger.mdwDebug( "SOAPListenerServlet failed to find correct Message Factory:" + "\n" + e.getMessage()); } // Try with the other unintuitive MessageFactory // factory = getMessageFactory(requestString, false); soapVersion = getSoapVersion(requestString, false); factory = getSoapMessageFactory(soapVersion); reqInputStream = new ByteArrayInputStream(requestString.getBytes()); message = factory.createMessage(null, reqInputStream); body = message.getSOAPBody(); // Only 2 versions, so let any exceptions bubble up } Node childElem = null; Iterator<?> it = body.getChildElements(); while (it.hasNext()) { Node node = (Node) it.next(); if (node.getNodeType() == Node.ELEMENT_NODE) { childElem = node; break; } } if (childElem == null) throw new SOAPException("SOAP body child element not found"); String requestXml = null; boolean oldStyleRpcRequest = false; if (request.getServletPath().endsWith(RPC_SERVICE_PATH) || RPC_SERVICE_PATH.equals(request.getPathInfo())) { NodeList nodes = childElem.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { if (StringUtils.isNotBlank(nodes.item(i).getNodeName()) && nodes.item(i).getNodeName().equals("RequestDetails")) { oldStyleRpcRequest = true; Node requestNode = nodes.item(i).getFirstChild(); if (requestNode.getNodeType() == Node.CDATA_SECTION_NODE) { requestXml = requestNode.getTextContent(); } else { requestXml = DomHelper.toXml(requestNode); if (requestXml.contains("<")) requestXml = StringEscapeUtils.unescapeXml(requestXml); } } } } else { requestXml = DomHelper.toXml(childElem); } metaInfo = addSoapMetaInfo(metaInfo, message); ListenerHelper helper = new ListenerHelper(); try { authenticate(request, metaInfo, requestXml); String handlerResponse = helper.processEvent(requestXml, metaInfo); try { // standard response indicates a potential problem MDWStatusMessageDocument responseDoc = MDWStatusMessageDocument.Factory.parse(handlerResponse, Compatibility.namespaceOptions()); MDWStatusMessage responseMsg = responseDoc.getMDWStatusMessage(); if ("SUCCESS".equals(responseMsg.getStatusMessage())) responseString = createSoapResponse(soapVersion, handlerResponse); else responseString = createSoapFaultResponse(soapVersion, String.valueOf(responseMsg.getStatusCode()), responseMsg.getStatusMessage()); } catch (XmlException xex) { if (Listener.METAINFO_ERROR_RESPONSE_VALUE .equalsIgnoreCase(metaInfo.get(Listener.METAINFO_ERROR_RESPONSE))) { // Support for custom error response responseString = handlerResponse; } else { // not parseable as standard response doc (a good thing) if (oldStyleRpcRequest) { responseString = createOldStyleSoapResponse(soapVersion, "<m:invokeWebServiceResponse xmlns:m=\"http://mdw.qwest.com/listener/webservice\"><Response>" + StringEscapeUtils.escapeXml(handlerResponse) + "</Response></m:invokeWebServiceResponse>"); } else { responseString = createSoapResponse(soapVersion, handlerResponse); } } } } catch (ServiceException ex) { logger.severeException(ex.getMessage(), ex); responseString = createSoapFaultResponse(soapVersion, String.valueOf(ex.getCode()), ex.getMessage()); } } catch (Exception ex) { logger.severeException(ex.getMessage(), ex); try { responseString = createSoapFaultResponse(soapVersion, null, ex.getMessage()); } catch (Exception tex) { logger.severeException(tex.getMessage(), tex); } } if (logger.isMdwDebugEnabled()) { logger.mdwDebug("SOAP Listener Servlet POST Response:\n" + responseString); } if (metaInfo.get(Listener.METAINFO_CONTENT_TYPE) != null) { response.setContentType(metaInfo.get(Listener.METAINFO_CONTENT_TYPE)); } else { if (soapVersion.equals(SOAPConstants.SOAP_1_1_PROTOCOL)) response.setContentType(Listener.CONTENT_TYPE_XML); else response.setContentType("application/soap+xml"); } response.getOutputStream().print(responseString); timer.stopAndLogTiming(""); }
From source file:it.cnr.icar.eric.server.interfaces.soap.RegistryBSTServlet.java
public SOAPMessage onMessage(SOAPMessage msg, HttpServletRequest req, HttpServletResponse resp) { //System.err.println("onMessage called for RegistrySOAPServlet"); SOAPMessage soapResponse = null; SOAPHeader sh = null;// ww w . ja va 2 s .c o m try { // set 'sh' variable ASAP (before "firstly") SOAPPart sp = msg.getSOAPPart(); SOAPEnvelope se = sp.getEnvelope(); SOAPBody sb = se.getBody(); sh = se.getHeader(); // Firstly we put save the attached repository items in a map HashMap<String, Object> idToRepositoryItemMap = new HashMap<String, Object>(); Iterator<?> apIter = msg.getAttachments(); while (apIter.hasNext()) { AttachmentPart ap = (AttachmentPart) apIter.next(); //Get the content for the attachment RepositoryItem ri = processIncomingAttachment(ap); idToRepositoryItemMap.put(ri.getId(), ri); } // Log received message //if (log.isTraceEnabled()) { // Warning! BAOS.toString() uses platform's default encoding /* ByteArrayOutputStream msgOs = new ByteArrayOutputStream(); msg.writeTo(msgOs); msgOs.close(); System.err.println(msgOs.toString()); */ //System.err.println(sb.getTextContent()); // log.trace("incoming message:\n" + msgOs.toString()); //} // verify signature // returns false if no security header, throws exception if invalid CredentialInfo credentialInfo = new CredentialInfo(); boolean noRegRequired = Boolean.valueOf( CommonProperties.getInstance().getProperty("eric.common.noUserRegistrationRequired", "false")) .booleanValue(); if (!noRegRequired) { WSS4JSecurityUtilBST.verifySOAPEnvelopeOnServerBST(se, credentialInfo); } //The ebXML registry request is the only element in the SOAPBody StringWriter requestXML = new StringWriter(); //The request as an XML String String requestRootElement = null; Iterator<?> iter = sb.getChildElements(); int i = 0; while (iter.hasNext()) { Object obj = iter.next(); if (!(obj instanceof SOAPElement)) { continue; } if (i++ == 0) { SOAPElement elem = (SOAPElement) obj; Name name = elem.getElementName(); requestRootElement = name.getLocalName(); StreamResult result = new StreamResult(requestXML); TransformerFactory tf = TransformerFactory.newInstance(); Transformer trans = tf.newTransformer(); trans.transform(new DOMSource(elem), result); } else { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.invalidRequest")); } } if (requestRootElement == null) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.noebXMLRegistryRequest")); } // unmarshalling request to message Object message = bu.getRequestObject(requestRootElement, requestXML.toString()); if (message instanceof JAXBElement<?>) { // If Element; take ComplexType from Element message = ((JAXBElement<?>) message).getValue(); } // request sets ServerContext with ComplexType: RegistryObjectType BSTRequest request = new BSTRequest(req, credentialInfo, message, idToRepositoryItemMap); Response response = request.process(); // response.getMessage() is ComplexType again soapResponse = createResponseSOAPMessage(response); if (response.getIdToRepositoryItemMap().size() > 0 && (response.getMessage().getStatus() .equals(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success))) { idToRepositoryItemMap = response.getIdToRepositoryItemMap(); Iterator<?> mapKeysIter = idToRepositoryItemMap.keySet().iterator(); while (mapKeysIter.hasNext()) { String id = (String) mapKeysIter.next(); RepositoryItem repositoryItem = (RepositoryItem) idToRepositoryItemMap.get(id); String cid = WSS4JSecurityUtilBST.convertUUIDToContentId(id); DataHandler dh = repositoryItem.getDataHandler(); AttachmentPart ap = soapResponse.createAttachmentPart(dh); ap.setMimeHeader("Content-Type", "text/xml"); ap.setContentId(cid); soapResponse.addAttachmentPart(ap); if (log.isTraceEnabled()) { log.trace("adding attachment: contentId=" + id); } } } } catch (Throwable t) { //Do not log ObjectNotFoundException as it clutters the log if (!(t instanceof ObjectNotFoundException)) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException", new Object[] { t.getMessage() }), t); Throwable cause = t.getCause(); while (cause != null) { log.error(ServerResourceBundle.getInstance().getString("message.CausedBy", new Object[] { cause.getMessage() }), cause); cause = cause.getCause(); } } soapResponse = createFaultSOAPMessage(t, sh); } if (log.isTraceEnabled()) { try { ByteArrayOutputStream rspOs = new ByteArrayOutputStream(); soapResponse.writeTo(rspOs); rspOs.close(); // Warning! BAOS.toString() uses platform's default encoding log.trace("response message:\n" + rspOs.toString()); } catch (Exception e) { log.error(ServerResourceBundle.getInstance().getString("message.FailedToLogResponseMessage", new Object[] { e.getMessage() }), e); } } return soapResponse; }
From source file:it.cnr.icar.eric.server.interfaces.soap.RegistrySAMLServlet.java
@SuppressWarnings("unchecked") public SOAPMessage onMessage(SOAPMessage msg, HttpServletRequest req, HttpServletResponse resp) { SOAPMessage soapResponse = null; SOAPHeader soapHeader = null; try {//from www . ja va 2 s. c o m // extract SOAP related parts from incoming SOAP message // set 'soapHeader' variable ASAP (before "firstly") SOAPPart soapPart = msg.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); soapHeader = soapEnvelope.getHeader(); /**************************************************************** * * REPOSITORY ITEM HANDLING (IN) REPOSITORY ITEM HANDLING (IN) * ***************************************************************/ // Firstly we put save the attached repository items in a map HashMap<String, Object> idToRepositoryItemMap = new HashMap<String, Object>(); Iterator<AttachmentPart> apIter = msg.getAttachments(); while (apIter.hasNext()) { AttachmentPart ap = apIter.next(); // Get the content for the attachment RepositoryItem ri = processIncomingAttachment(ap); idToRepositoryItemMap.put(ri.getId(), ri); } /**************************************************************** * * LOGGING (IN) LOGGING (IN) LOGGING (IN) LOGGING (IN) * ***************************************************************/ // Log received message if (log.isTraceEnabled()) { // Warning! BAOS.toString() uses platform's default encoding ByteArrayOutputStream msgOs = new ByteArrayOutputStream(); msg.writeTo(msgOs); msgOs.close(); log.trace("incoming message:\n" + msgOs.toString()); } /**************************************************************** * * MESSAGE VERIFICATION (IN) MESSAGE VERIFICATION (IN) * ***************************************************************/ CredentialInfo credentialInfo = new CredentialInfo(); WSS4JSecurityUtilSAML.verifySOAPEnvelopeOnServerSAML(soapEnvelope, credentialInfo); /**************************************************************** * * RS:REQUEST HANDLING RS:REQUEST HANDLING RS:REQUEST * ***************************************************************/ // The ebXML registry request is the only element in the SOAPBody StringWriter requestXML = new StringWriter(); // The request as an // XML String String requestRootElement = null; Iterator<?> iter = soapBody.getChildElements(); int i = 0; while (iter.hasNext()) { Object obj = iter.next(); if (!(obj instanceof SOAPElement)) { continue; } if (i++ == 0) { SOAPElement elem = (SOAPElement) obj; Name name = elem.getElementName(); requestRootElement = name.getLocalName(); StreamResult result = new StreamResult(requestXML); TransformerFactory tf = TransformerFactory.newInstance(); Transformer trans = tf.newTransformer(); trans.transform(new DOMSource(elem), result); } else { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.invalidRequest")); } } if (requestRootElement == null) { throw new RegistryException( ServerResourceBundle.getInstance().getString("message.noebXMLRegistryRequest")); } // unmarshalling request to message Object message = bu.getRequestObject(requestRootElement, requestXML.toString()); if (message instanceof JAXBElement<?>) { // If Element; take ComplexType from Element message = ((JAXBElement<?>) message).getValue(); } SAMLRequest request = new SAMLRequest(req, credentialInfo.assertion, message, idToRepositoryItemMap); Response response = request.process(); /**************************************************************** * * RESPONSE HANDLING RESPONSE HANDLING RESPONSE HANDLING * ***************************************************************/ soapResponse = createResponseSOAPMessage(response); if (response.getIdToRepositoryItemMap().size() > 0 && (response.getMessage().getStatus() .equals(BindingUtility.CANONICAL_RESPONSE_STATUS_TYPE_ID_Success))) { idToRepositoryItemMap = response.getIdToRepositoryItemMap(); Iterator<String> mapKeysIter = idToRepositoryItemMap.keySet().iterator(); while (mapKeysIter.hasNext()) { String id = mapKeysIter.next(); RepositoryItem repositoryItem = (RepositoryItem) idToRepositoryItemMap.get(id); String cid = WSS4JSecurityUtilSAML.convertUUIDToContentId(id); DataHandler dh = repositoryItem.getDataHandler(); AttachmentPart ap = soapResponse.createAttachmentPart(dh); ap.setContentId(cid); soapResponse.addAttachmentPart(ap); if (log.isTraceEnabled()) { log.trace("adding attachment: contentId=" + id); } } } } catch (Throwable t) { // Do not log ObjectNotFoundException as it clutters the log if (!(t instanceof ObjectNotFoundException)) { log.error(ServerResourceBundle.getInstance().getString("message.CaughtException", new Object[] { t.getMessage() }), t); Throwable cause = t.getCause(); while (cause != null) { log.error(ServerResourceBundle.getInstance().getString("message.CausedBy", new Object[] { cause.getMessage() }), cause); cause = cause.getCause(); } } soapResponse = createFaultSOAPMessage(t, soapHeader); } if (log.isTraceEnabled()) { try { ByteArrayOutputStream rspOs = new ByteArrayOutputStream(); soapResponse.writeTo(rspOs); rspOs.close(); // Warning! BAOS.toString() uses platform's default encoding log.trace("response message:\n" + rspOs.toString()); } catch (Exception e) { log.error(ServerResourceBundle.getInstance().getString("message.FailedToLogResponseMessage", new Object[] { e.getMessage() }), e); } } return soapResponse; }
From source file:nl.nn.adapterframework.extensions.cxf.NamespaceUriProvider.java
public String findNamespaceUri() throws ListenerException { log.debug("trying to find serviceName from soapMessage[" + soapMessage + "]"); try {//www .j a v a2 s . c o m SOAPBody body = soapMessage.getSOAPBody(); if (body.hasChildNodes()) { Iterator<?> it = body.getChildElements(); while (it.hasNext()) { Node node = (Node) it.next(); //Found first namespaceURI if (StringUtils.isNotEmpty(node.getNamespaceURI())) return node.getNamespaceURI(); } } } catch (SOAPException e) { throw new ListenerException(e); } throw new ListenerException("unable to determine serviceName from NamespaceURI"); }
From source file:org.apache.axis.handlers.HandlerChainImpl.java
public ArrayList getMessageInfo(SOAPMessage message) { ArrayList list = new ArrayList(); try {//from w w w . j ava2 s.c o m 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; }
From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java
/** * locate "root" in DisoverResponse/*from ww w . java2 s .com*/ */ private SOAPElement findDiscoverRoot(final SOAPMessage reply) throws SOAPException, XMLAException { SOAPPart sp = reply.getSOAPPart(); SOAPEnvelope envelope = sp.getEnvelope(); SOAPBody body = envelope.getBody(); Name childName; SOAPElement eResponse = null; if (provider == 0) { // unknown provider - recognize by prefix of DiscoverResponse Iterator itBody = body.getChildElements(); while (itBody.hasNext()) { Node n = (Node) itBody.next(); if (!(n instanceof SOAPElement)) { continue; } Name name = ((SOAPElement) n).getElementName(); if (name.getLocalName().equals("DiscoverResponse")) { //$NON-NLS-1$ eResponse = (SOAPElement) n; provider = getProviderFromDiscoverResponse(envelope, eResponse); break; } } if (eResponse == null) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0013_NO_DISCOVER_RESPONSE")); //$NON-NLS-1$ } } else { if ((provider == XMLABaseComponent.PROVIDER_MICROSOFT) || (provider == XMLABaseComponent.PROVIDER_ESSBASE)) { // Microsoft // or // Essbase childName = envelope.createName("DiscoverResponse", "m", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$ //$NON-NLS-2$ } else if ((provider == XMLABaseComponent.PROVIDER_SAP) || (provider == XMLABaseComponent.PROVIDER_MONDRIAN)) { // SAP // or // Mondrian childName = envelope.createName("DiscoverResponse", "", XMLABaseComponent.XMLA_URI); //$NON-NLS-1$ //$NON-NLS-2$ } else { throw new IllegalArgumentException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0014_NO_PROVIDER_SPEC")); //$NON-NLS-1$ } eResponse = selectSingleNode(body, childName); if (eResponse == null) { throw new XMLAException(Messages.getInstance() .getString("XMLABaseComponent.ERROR_0015_NO_DISCOVER_RESPONSE_ELEMENT")); //$NON-NLS-1$ } } SOAPElement eReturn = getDiscoverReturn(envelope, eResponse); if (eReturn == null) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0016_NO_RESULT_RETURN_ELEMENT")); //$NON-NLS-1$ } SOAPElement eRoot = getDiscoverRoot(envelope, eReturn); if (eRoot == null) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0017_NO_RESULT_ROOT_ELEMENT")); //$NON-NLS-1$ } return eRoot; }