javax.xml.soap.SOAPBody Java Examples
The following examples show how to use
javax.xml.soap.SOAPBody.
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: 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 #2
Source File: SaajEmptyNamespaceTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null); childGlobalNS.addNamespaceDeclaration("", null); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(TEST_NS, childDefaultNS.getNamespaceURI()); }
Example #3
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 #4
Source File: SoapProtocol.java From jolie with GNU Lesser General Public License v2.1 | 6 votes |
private void setOutputEncodingStyle( SOAPEnvelope soapEnvelope, String operationName ) throws IOException, SOAPException { Port port = getWSDLPort(); if( port != null ) { BindingOperation bindingOperation = port.getBinding().getBindingOperation( operationName, null, null ); if( bindingOperation == null ) { return; } BindingOutput output = bindingOperation.getBindingOutput(); if( output == null ) { return; } for( ExtensibilityElement element : (List< ExtensibilityElement >) output.getExtensibilityElements() ) { if( element instanceof javax.wsdl.extensions.soap.SOAPBody ) { List< String > list = ((javax.wsdl.extensions.soap.SOAPBody) element).getEncodingStyles(); if( list != null && list.isEmpty() == false ) { soapEnvelope.setEncodingStyle( list.get( 0 ) ); soapEnvelope.addNamespaceDeclaration( "enc", list.get( 0 ) ); } } } } }
Example #5
Source File: SchemaValidatorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void validate(SOAPMessageContext context, String mode) { try { SOAPBody body = context.getMessage().getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { return; } Node payloadNode = body.getFirstChild(); ValidatorHelper.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles); } catch (Exception var6) { dumpMessage(context.getMessage(), mode, LOG); LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage()); throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6); } LOG.info("Message validation done."); }
Example #6
Source File: SaajEmptyNamespaceTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToGlobalNsQName() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName("", "global-child")); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(),TEST_NS); }
Example #7
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 #8
Source File: SaajEmptyNamespaceTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToGlobalNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", ""); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS); }
Example #9
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); } 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()); } }
Example #10
Source File: Inflate.java From tomee with Apache License 2.0 | 6 votes |
public boolean handleMessage(SOAPMessageContext mc) { try { final SOAPMessage message = mc.getMessage(); final SOAPBody body = message.getSOAPBody(); final String localName = body.getFirstChild().getLocalName(); if ("sumResponse".equals(localName) || "multiplyResponse".equals(localName)) { final Node responseNode = body.getFirstChild(); final Node returnNode = responseNode.getFirstChild(); final Node intNode = returnNode.getFirstChild(); final int value = new Integer(intNode.getNodeValue()); intNode.setNodeValue(Integer.toString(value * 1000)); } return true; } catch (SOAPException e) { return false; } }
Example #11
Source File: SchemaValidatorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void validate(SOAPMessageContext context, String mode) { try { SOAPBody body = context.getMessage().getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { return; } Node payloadNode = body.getFirstChild(); ValidatorHelper.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles); } catch (Exception var6) { dumpMessage(context.getMessage(), mode, LOG); LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage()); throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6); } LOG.info("Message validation done."); }
Example #12
Source File: NamespaceUriProvider.java From iaf with Apache License 2.0 | 6 votes |
public String findNamespaceUri() throws ListenerException { log.debug("trying to find serviceName from soapMessage["+soapMessage+"]"); try { 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"); }
Example #13
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 #14
Source File: SchemaValidatorHandler.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private void validate(SOAPMessageContext context, String mode) { try { SOAPBody body = context.getMessage().getSOAPBody(); SOAPFault fault = body.getFault(); if (fault != null) { return; } Node payloadNode = body.getFirstChild(); ValidatorHelper.Companion.validate(new DOMSource(payloadNode), this.isXOPEnabled(context), this.schemaFiles); } catch (Exception var6) { dumpMessage(context.getMessage(), mode, LOG); LOG.error(var6.getClass().getSimpleName() + ": " + var6.getMessage()); throw SOAPFaultFactory.newSOAPFaultException(var6.getMessage(), var6); } LOG.info("Message validation done."); }
Example #15
Source File: Soap.java From keycloak with Apache License 2.0 | 6 votes |
/** * <p>Returns a string encoded accordingly with the SAML HTTP POST Binding specification based on the * given <code>inputStream</code> which must contain a valid SOAP message. * * <p>The resulting string is based on the Body of the SOAP message, which should map to a valid SAML message. * * @param inputStream the input stream containing a valid SOAP message with a Body that contains a SAML message * * @return a string encoded accordingly with the SAML HTTP POST Binding specification */ public static String toSamlHttpPostMessage(InputStream inputStream) { try { MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory.createMessage(null, inputStream); SOAPBody soapBody = soapMessage.getSOAPBody(); Node authnRequestNode = soapBody.getFirstChild(); Document document = DocumentUtil.createDocument(); document.appendChild(document.importNode(authnRequestNode, true)); return PostBindingUtil.base64Encode(DocumentUtil.asString(document)); } catch (Exception e) { throw new RuntimeException("Error creating fault message.", e); } }
Example #16
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 #17
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToGlobalNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", ""); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS); }
Example #18
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null); childGlobalNS.addNamespaceDeclaration("", null); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(TEST_NS, childDefaultNS.getNamespaceURI()); }
Example #19
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToGlobalNsQName() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName("", "global-child")); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(),TEST_NS); }
Example #20
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNsQName() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName(null, "global-child")); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS); }
Example #21
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToGlobalNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", ""); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS); }
Example #22
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null); childGlobalNS.addNamespaceDeclaration("", null); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(TEST_NS, childDefaultNS.getNamespaceURI()); }
Example #23
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNsQName() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName(null, "global-child")); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS); }
Example #24
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToGlobalNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", ""); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS); }
Example #25
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null); childGlobalNS.addNamespaceDeclaration("", null); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(TEST_NS, childDefaultNS.getNamespaceURI()); }
Example #26
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToGlobalNsQName() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName("", "global-child")); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(),TEST_NS); }
Example #27
Source File: SaajEmptyNamespaceTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNsQName() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName(null, "global-child")); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS); }
Example #28
Source File: Increment.java From tomee with Apache License 2.0 | 6 votes |
public boolean handleMessage(SOAPMessageContext mc) { try { final SOAPMessage message = mc.getMessage(); final SOAPBody body = message.getSOAPBody(); final String localName = body.getFirstChild().getLocalName(); if ("sumResponse".equals(localName) || "multiplyResponse".equals(localName)) { final Node responseNode = body.getFirstChild(); final Node returnNode = responseNode.getFirstChild(); final Node intNode = returnNode.getFirstChild(); final int value = new Integer(intNode.getNodeValue()); intNode.setNodeValue(Integer.toString(value + 1)); } return true; } catch (SOAPException e) { return false; } }
Example #29
Source File: SaajEmptyNamespaceTest.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNs() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null); childGlobalNS.addNamespaceDeclaration("", null); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(TEST_NS, childDefaultNS.getNamespaceURI()); }
Example #30
Source File: SaajEmptyNamespaceTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Test public void testAddElementToNullNsQName() throws Exception { // Create empty SOAP message SOAPMessage msg = createSoapMessage(); SOAPBody body = msg.getSOAPPart().getEnvelope().getBody(); // Add elements SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS); parentExplicitNS.addNamespaceDeclaration("", TEST_NS); SOAPElement childGlobalNS = parentExplicitNS.addChildElement(new QName(null, "global-child")); childGlobalNS.addNamespaceDeclaration("", ""); SOAPElement grandChildGlobalNS = childGlobalNS.addChildElement("global-grand-child"); SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child"); // Check namespace URIs Assert.assertNull(childGlobalNS.getNamespaceURI()); Assert.assertNull(grandChildGlobalNS.getNamespaceURI()); Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS); }