Java Code Examples for javax.xml.soap.SOAPEnvelope#getBody()
The following examples show how to use
javax.xml.soap.SOAPEnvelope#getBody() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HubDecryptionHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void handleDecryption(SOAPMessageContext cxt) { try { SOAPMessage soapMessage = cxt.getMessage(); SOAPBody soapBody = soapMessage.getSOAPBody(); if (soapBody == null) { SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope(); soapBody = soapEnvelope.getBody(); } FolderDecryptor.decryptFolder(soapBody, this.crypto); soapMessage.saveChanges(); } catch (SOAPException var5) { LOG.error("SOAPException when handling the SOAP Body", var5); throw new RuntimeException(var5); } catch (UnsealConnectorException var6) { LOG.error("UnsealConnectorException when handling the SOAP Message: " + var6.getMessage()); throw new FolderDecryptionRuntimeException(var6.getMessage(), var6); } catch (TechnicalConnectorException var7) { LOG.error("TechnicalConnectorException when handling the SOAP Message: " + var7.getMessage()); throw new RuntimeException(var7); } }
Example 2
Source File: SoapFaultHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private String getSoapFaultCode(SOAPMessage msg) throws SOAPException{ SOAPPart part = msg.getSOAPPart(); if(part !=null){ SOAPEnvelope soapEnvelope = part.getEnvelope(); if(soapEnvelope !=null){ SOAPBody body = soapEnvelope.getBody(); if(body !=null){ SOAPFault fault=body.getFault(); if(fault !=null && !StringUtils.isEmpty(fault.getFaultString()) && fault.getFaultString().contains("SOA-")){ return fault.getFaultString(); } } } } return null; }
Example 3
Source File: SoapFaultHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private String getSoapFaultCode(SOAPMessage msg) throws SOAPException{ SOAPPart part = msg.getSOAPPart(); if(part !=null){ SOAPEnvelope soapEnvelope = part.getEnvelope(); if(soapEnvelope !=null){ SOAPBody body = soapEnvelope.getBody(); if(body !=null){ SOAPFault fault=body.getFault(); if(fault !=null && !StringUtils.isEmpty(fault.getFaultString()) && fault.getFaultString().contains("SOA-")){ return fault.getFaultString(); } } } } return null; }
Example 4
Source File: HubDecryptionHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void handleDecryption(SOAPMessageContext cxt) { try { SOAPMessage soapMessage = cxt.getMessage(); SOAPBody soapBody = soapMessage.getSOAPBody(); if (soapBody == null) { SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope(); soapBody = soapEnvelope.getBody(); } FolderDecryptor.decryptFolder(soapBody, this.crypto); soapMessage.saveChanges(); } catch (SOAPException var5) { LOG.error("SOAPException when handling the SOAP Body", var5); throw new RuntimeException(var5); } catch (UnsealConnectorException var6) { LOG.error("UnsealConnectorException when handling the SOAP Message: " + var6.getMessage()); throw new FolderDecryptionRuntimeException(var6.getMessage(), var6); } catch (TechnicalConnectorException var7) { LOG.error("TechnicalConnectorException when handling the SOAP Message: " + var7.getMessage()); throw new RuntimeException(var7); } }
Example 5
Source File: HubDecryptionHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void handleDecryption(SOAPMessageContext cxt) { try { SOAPMessage soapMessage = cxt.getMessage(); SOAPBody soapBody = soapMessage.getSOAPBody(); if (soapBody == null) { SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope(); soapBody = soapEnvelope.getBody(); } FolderDecryptor.decryptFolder(soapBody, this.crypto); soapMessage.saveChanges(); } catch (SOAPException var5) { LOG.error("SOAPException when handling the SOAP Body", var5); throw new RuntimeException(var5); } catch (UnsealConnectorException var6) { LOG.error("UnsealConnectorException when handling the SOAP Message: " + var6.getMessage()); throw new FolderDecryptionRuntimeException(var6.getMessage(), var6); } catch (TechnicalConnectorException var7) { LOG.error("TechnicalConnectorException when handling the SOAP Message: " + var7.getMessage()); throw new RuntimeException(var7); } }
Example 6
Source File: SoapFaultHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private String getSoapFaultCode(SOAPMessage msg) throws SOAPException{ SOAPPart part = msg.getSOAPPart(); if(part !=null){ SOAPEnvelope soapEnvelope = part.getEnvelope(); if(soapEnvelope !=null){ SOAPBody body = soapEnvelope.getBody(); if(body !=null){ SOAPFault fault=body.getFault(); if(fault !=null && !StringUtils.isEmpty(fault.getFaultString()) && fault.getFaultString().contains("SOA-")){ return fault.getFaultString(); } } } } return null; }
Example 7
Source File: ArcherAuthenticatingRestConnection.java From FortifyBugTrackerUtility with MIT License | 5 votes |
public Long addValueToValuesList(Long valueListId, String value) { LOG.info("[Archer] Adding value '"+value+"' to value list id "+valueListId); // Adding items to value lists is not supported via REST API, so we need to revert to SOAP API // TODO Simplify this method? // TODO Make this method more fail-safe (like checking for the correct response element)? Long result = null; try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage message = messageFactory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); SOAPElement bodyElement = body.addChildElement(envelope.createName("CreateValuesListValue", "", "http://archer-tech.com/webservices/")); bodyElement.addChildElement("sessionToken").addTextNode(tokenProviderRest.getToken()); bodyElement.addChildElement("valuesListId").addTextNode(valueListId+""); bodyElement.addChildElement("valuesListValueName").addTextNode(value); message.saveChanges(); SOAPMessage response = executeRequest(HttpMethod.POST, getBaseResource().path("/ws/field.asmx") .request() .header("SOAPAction", "\"http://archer-tech.com/webservices/CreateValuesListValue\"") .accept("text/xml"), Entity.entity(message, "text/xml"), SOAPMessage.class); @SuppressWarnings("unchecked") Iterator<Object> it = response.getSOAPBody().getChildElements(); while (it.hasNext()){ Object o = it.next(); if ( o instanceof SOAPElement ) { result = new Long(((SOAPElement)o).getTextContent()); } } System.out.println(response); } catch (SOAPException e) { throw new RuntimeException("Error executing SOAP request", e); } return result; }
Example 8
Source File: SignCodeMojo.java From sling-whiteboard with Apache License 2.0 | 5 votes |
private static SOAPBody populateEnvelope(SOAPMessage message, String namespace) throws SOAPException { SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); envelope.addNamespaceDeclaration( "soapenv","http://schemas.xmlsoap.org/soap/envelope/"); envelope.addNamespaceDeclaration( namespace,"http://api.ws.symantec.com/webtrust/codesigningservice"); return envelope.getBody(); }
Example 9
Source File: SOAPUtils.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static SOAPMessage newSOAPMessage(String payload) throws TechnicalConnectorException { try { SOAPMessage response = MF.createMessage(); SOAPPart soapPart = response.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); soapBody.addDocument(ConnectorXmlUtils.toDocument(payload)); return response; } catch (Exception ex) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_TECHNICAL, ex); } }
Example 10
Source File: AbstractWsSender.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
protected SOAPMessageContext createSOAPMessageCtx(GenericRequest genericRequest) throws TechnicalConnectorException { try { SOAPMessage soapMessage = mf.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (genericRequest.isXopEnabled()) { soapMessage.getMimeHeaders().addHeader("Content-Type", "application/xop+xml"); soapPart.addMimeHeader("Content-ID", "<[email protected]>"); soapPart.addMimeHeader("Content-Transfer-Encoding", "8bit"); } SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); soapBody.addDocument(genericRequest.getPayload()); Map<String, DataHandler> handlers = genericRequest.getDataHandlerMap(); AttachmentPart part; for(Iterator i$ = handlers.entrySet().iterator(); i$.hasNext(); soapMessage.addAttachmentPart(part)) { Entry<String, DataHandler> handlerEntry = (Entry)i$.next(); DataHandler handler = (DataHandler)handlerEntry.getValue(); part = soapMessage.createAttachmentPart(handler); part.setContentType(handler.getContentType()); if (genericRequest.isXopEnabled()) { part.addMimeHeader("Content-Transfer-Encoding", "binary"); part.setContentId("<" + (String)handlerEntry.getKey() + ">"); } else { part.setContentId((String)handlerEntry.getKey()); } } return createSOAPMessageCtx(soapMessage); } catch (SOAPException var11) { throw translate(var11); } }
Example 11
Source File: AbstractWsSender.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
protected SOAPMessageContext createSOAPMessageCtx(GenericRequest genericRequest) throws TechnicalConnectorException { try { SOAPMessage soapMessage = mf.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (genericRequest.isXopEnabled()) { soapMessage.getMimeHeaders().addHeader("Content-Type", "application/xop+xml"); soapPart.addMimeHeader("Content-ID", "<[email protected]>"); soapPart.addMimeHeader("Content-Transfer-Encoding", "8bit"); } SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); soapBody.addDocument(genericRequest.getPayload()); Map<String, DataHandler> handlers = genericRequest.getDataHandlerMap(); AttachmentPart part; for(Iterator i$ = handlers.entrySet().iterator(); i$.hasNext(); soapMessage.addAttachmentPart(part)) { Entry<String, DataHandler> handlerEntry = (Entry)i$.next(); DataHandler handler = (DataHandler)handlerEntry.getValue(); part = soapMessage.createAttachmentPart(handler); part.setContentType(handler.getContentType()); if (genericRequest.isXopEnabled()) { part.addMimeHeader("Content-Transfer-Encoding", "binary"); part.setContentId("<" + (String)handlerEntry.getKey() + ">"); } else { part.setContentId((String)handlerEntry.getKey()); } } return createSOAPMessageCtx(soapMessage); } catch (SOAPException var11) { throw translate(var11); } }
Example 12
Source File: AbstractWsSender.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
protected SOAPMessageContext createSOAPMessageCtx(GenericRequest genericRequest) throws TechnicalConnectorException { try { SOAPMessage soapMessage = mf.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); if (genericRequest.isXopEnabled()) { soapMessage.getMimeHeaders().addHeader("Content-Type", "application/xop+xml"); soapPart.addMimeHeader("Content-ID", "<[email protected]>"); soapPart.addMimeHeader("Content-Transfer-Encoding", "8bit"); } SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); soapBody.addDocument(genericRequest.getPayload()); Map<String, DataHandler> handlers = genericRequest.getDataHandlerMap(); AttachmentPart part; for(Iterator i$ = handlers.entrySet().iterator(); i$.hasNext(); soapMessage.addAttachmentPart(part)) { Entry<String, DataHandler> handlerEntry = (Entry)i$.next(); DataHandler handler = (DataHandler)handlerEntry.getValue(); part = soapMessage.createAttachmentPart(handler); part.setContentType(handler.getContentType()); if (genericRequest.isXopEnabled()) { part.addMimeHeader("Content-Transfer-Encoding", "binary"); part.setContentId("<" + (String)handlerEntry.getKey() + ">"); } else { part.setContentId((String)handlerEntry.getKey()); } } return createSOAPMessageCtx(soapMessage); } catch (SOAPException var11) { throw translate(var11); } }
Example 13
Source File: SOAPUtils.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static SOAPMessage newSOAPMessage(String payload) throws TechnicalConnectorException { try { SOAPMessage response = MF.createMessage(); SOAPPart soapPart = response.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); soapBody.addDocument(ConnectorXmlUtils.toDocument(payload)); return response; } catch (Exception var5) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_TECHNICAL, var5, new Object[0]); } }
Example 14
Source File: JPlagServerAccessHandler.java From jplag with GNU General Public License v3.0 | 5 votes |
/** * Manually builds up a JPlagException SOAP message and replaces the * original one with it */ public void replaceByJPlagException(SOAPMessageContext smsg, String desc, String rep) { try { SOAPMessage msg = smsg.getMessage(); SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope(); /* * Remove old header andy body */ SOAPHeader oldheader = envelope.getHeader(); if (oldheader != null) oldheader.detachNode(); SOAPBody oldbody = envelope.getBody(); if (oldbody != null) oldbody.detachNode(); SOAPBody sb = envelope.addBody(); SOAPFault sf = sb.addFault(envelope.createName("Server", "env", SOAPConstants.URI_NS_SOAP_ENVELOPE), "jplagWebService.server.JPlagException"); Detail detail = sf.addDetail(); DetailEntry de = detail.addDetailEntry(envelope.createName("JPlagException", "ns0", JPLAG_WEBSERVICE_BASE_URL + "types")); SOAPElement e = de.addChildElement("exceptionType"); e.addTextNode("accessException"); e = de.addChildElement("description"); e.addTextNode(desc); e = de.addChildElement("repair"); e.addTextNode(rep); } catch (SOAPException x) { x.printStackTrace(); } }
Example 15
Source File: SOAPUtils.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static SOAPMessage newSOAPMessage(String payload) throws TechnicalConnectorException { try { SOAPMessage response = MF.createMessage(); SOAPPart soapPart = response.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getEnvelope(); SOAPBody soapBody = soapEnvelope.getBody(); soapBody.addDocument(ConnectorXmlUtils.toDocument(payload)); return response; } catch (Exception var5) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_TECHNICAL, var5, new Object[0]); } }
Example 16
Source File: Tr064Comm.java From openhab1-addons with Eclipse Public License 2.0 | 5 votes |
/** * Sets all required namespaces and prepares the SOAP message to send. * Creates skeleton + body data. * * @param bodyData * is attached to skeleton to form entire SOAP message * @return ready to send SOAP message */ private SOAPMessage constructTr064Msg(SOAPBodyElement bodyData) { SOAPMessage soapMsg = null; try { MessageFactory msgFac; msgFac = MessageFactory.newInstance(); soapMsg = msgFac.createMessage(); soapMsg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true"); soapMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8"); SOAPPart part = soapMsg.getSOAPPart(); // valid for entire SOAP msg String namespace = "s"; // create suitable fbox envelope SOAPEnvelope envelope = part.getEnvelope(); envelope.setPrefix(namespace); envelope.removeNamespaceDeclaration("SOAP-ENV"); // delete standard namespace which was already set envelope.addNamespaceDeclaration(namespace, "http://schemas.xmlsoap.org/soap/envelope/"); Name nEncoding = envelope.createName("encodingStyle", namespace, "http://schemas.xmlsoap.org/soap/encoding/"); envelope.addAttribute(nEncoding, "http://schemas.xmlsoap.org/soap/encoding/"); // create empty header SOAPHeader header = envelope.getHeader(); header.setPrefix(namespace); // create body with command based on parameter SOAPBody body = envelope.getBody(); body.setPrefix(namespace); body.addChildElement(bodyData); // bodyData already prepared. Needs only be added } catch (Exception e) { logger.error("Error creating SOAP message for fbox request with data {}", bodyData); e.printStackTrace(); } return soapMsg; }
Example 17
Source File: CompilatioAPIUtil.java From sakai with Educational Community License v2.0 | 4 votes |
public static Document callCompilatioReturnDocument(String apiURL, Map<String, String> parameters, String secretKey, final int timeout) throws TransientSubmissionException, SubmissionException { SOAPConnectionFactory soapConnectionFactory; Document xmlDocument = null; try { soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(); SOAPPart soapPart = soapMessage.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody soapBody = envelope.getBody(); SOAPElement soapBodyAction = soapBody.addChildElement(parameters.get("action")); parameters.remove("action"); // api key SOAPElement soapBodyKey = soapBodyAction.addChildElement("key"); soapBodyKey.addTextNode(secretKey); Set<Entry<String, String>> ets = parameters.entrySet(); Iterator<Entry<String, String>> it = ets.iterator(); while (it.hasNext()) { Entry<String, String> param = it.next(); SOAPElement soapBodyElement = soapBodyAction.addChildElement(param.getKey()); soapBodyElement.addTextNode(param.getValue()); } URL endpoint = new URL(null, apiURL, new URLStreamHandler() { @Override protected URLConnection openConnection(URL url) throws IOException { URL target = new URL(url.toString()); URLConnection connection = target.openConnection(); // Connection settings connection.setConnectTimeout(timeout); connection.setReadTimeout(timeout); return(connection); } }); SOAPMessage soapResponse = soapConnection.call(soapMessage, endpoint); // loading the XML document ByteArrayOutputStream out = new ByteArrayOutputStream(); soapResponse.writeTo(out); DocumentBuilderFactory builderfactory = DocumentBuilderFactory.newInstance(); builderfactory.setNamespaceAware(true); DocumentBuilder builder = builderfactory.newDocumentBuilder(); xmlDocument = builder.parse(new InputSource(new StringReader(out.toString()))); soapConnection.close(); } catch (UnsupportedOperationException | SOAPException | IOException | ParserConfigurationException | SAXException e) { log.error(e.getLocalizedMessage(), e); } return xmlDocument; }
Example 18
Source File: SOAPGenerator.java From cougar with Apache License 2.0 | 4 votes |
public static SOAPMessageExchange buildSOAPMessagePARAMSTYLES(HttpCallBean httpCallBean) { //set up the param fields String headerParam; String queryParam; headerParam = "FOO"; //TODO this could be randomised for additional coverage queryParam = StringHelpers.generateRandomString(RAND_STRING_LENGTH, "UPPER"); SOAPMessage message = generateSOAPMessageShell(httpCallBean); SOAPMessageExchange msgEx = new SOAPMessageExchange(); SOAPEnvelope envelope; try { envelope = message.getSOAPPart().getEnvelope(); SOAPBody body; body = envelope.getBody(); SOAPElement root = body.addChildElement( "TestParameterStylesRequest", BAS, httpCallBean .getNameSpace()); root.addChildElement( envelope.createName("HeaderParam", BAS, httpCallBean .getNameSpace())).addTextNode(headerParam); root.addChildElement( envelope.createName("queryParam", BAS, httpCallBean .getNameSpace())).addTextNode(queryParam); } catch (SOAPException e) { throw new RuntimeException(e); } String resp = "headerParam=" + headerParam +",queryParam=" + queryParam; msgEx.setRequest(message); msgEx.setResponse(generateExpectedResultShell(resp)); return msgEx; }
Example 19
Source File: JRXmlaQueryExecuter.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
protected SOAPMessage createQueryMessage() { String queryStr = getQueryString(); if (log.isDebugEnabled()) { log.debug("MDX query: " + queryStr); } try { MessageFactory mf = MessageFactory.newInstance(); SOAPMessage message = mf.createMessage(); MimeHeaders mh = message.getMimeHeaders(); mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Execute\""); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); Name nEx = envelope.createName("Execute", "", XMLA_URI); SOAPElement eEx = body.addChildElement(nEx); // add the parameters // COMMAND parameter // <Command> // <Statement>queryStr</Statement> // </Command> Name nCom = envelope.createName("Command", "", XMLA_URI); SOAPElement eCommand = eEx.addChildElement(nCom); Name nSta = envelope.createName("Statement", "", XMLA_URI); SOAPElement eStatement = eCommand.addChildElement(nSta); eStatement.addTextNode(queryStr); // <Properties> // <PropertyList> // <DataSourceInfo>dataSource</DataSourceInfo> // <Catalog>catalog</Catalog> // <Format>Multidimensional</Format> // <AxisFormat>TupleFormat</AxisFormat> // </PropertyList> // </Properties> Map<String, String> paraList = new HashMap<String, String>(); String datasource = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE); paraList.put("DataSourceInfo", datasource); String catalog = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG); paraList.put("Catalog", catalog); paraList.put("Format", "Multidimensional"); paraList.put("AxisFormat", "TupleFormat"); addParameterList(envelope, eEx, "Properties", "PropertyList", paraList); message.saveChanges(); if (log.isDebugEnabled()) { log.debug("XML/A query message: \n" + prettyPrintSOAP(message.getSOAPPart().getEnvelope())); } return message; } catch (SOAPException e) { throw new JRRuntimeException(e); } }
Example 20
Source File: SOAPGenerator.java From cougar with Apache License 2.0 | 3 votes |
public static SOAPMessageExchange buildSOAPMessageSIMPLEGET(HttpCallBean httpCallBean) { SOAPMessageExchange msgEx = new SOAPMessageExchange(); SOAPMessage message = generateSOAPMessageShell(httpCallBean); SOAPEnvelope envelope; String content = StringHelpers.generateRandomString(RAND_STRING_LENGTH, "UPPER"); try { envelope = message.getSOAPPart().getEnvelope(); SOAPBody body; body = envelope.getBody(); SOAPElement root = body.addChildElement( "TestSimpleGetRequest", BAS, httpCallBean .getNameSpace()); root.addChildElement(MESSAGE, BAS, httpCallBean.getNameSpace()).addTextNode(content); } catch (SOAPException e) { throw new RuntimeException(e); } msgEx.setRequest(message); msgEx.setResponse(generateExpectedResultShell(content)); return msgEx; }