Java Code Examples for javax.xml.soap.SOAPBody#addChildElement()

The following examples show how to use javax.xml.soap.SOAPBody#addChildElement() . 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: SaajEmptyNamespaceTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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 2
Source File: SaajEmptyNamespaceTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@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 3
Source File: SaajEmptyNamespaceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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 4
Source File: SaajEmptyNamespaceTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 5
Source File: SaajEmptyNamespaceTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 6
Source File: SaajEmptyNamespaceTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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 7
Source File: SaajEmptyNamespaceTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 8
Source File: SaajEmptyNamespaceTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 9
Source File: SaajEmptyNamespaceTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 10
Source File: SaajEmptyNamespaceTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 11
Source File: SaajEmptyNamespaceTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 12
Source File: SaajEmptyNamespaceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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 13
Source File: SaajEmptyNamespaceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testAddElementToNullNsNoDeclarations() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null);
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
 
Example 14
Source File: Tr064Comm.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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 15
Source File: SaajEmptyNamespaceTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testAddElementToNullNsNoDeclarations() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null);
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
 
Example 16
Source File: SaajEmptyNamespaceTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testAddElementToNullNsNoDeclarations() throws Exception {
    // Create empty SOAP message
    SOAPMessage msg = createSoapMessage();
    SOAPBody body = msg.getSOAPPart().getEnvelope().getBody();

    // Add elements
    SOAPElement parentExplicitNS = body.addChildElement("content", "", TEST_NS);
    SOAPElement childGlobalNS = parentExplicitNS.addChildElement("global-child", "", null);
    SOAPElement childDefaultNS = parentExplicitNS.addChildElement("default-child");

    // Check namespace URIs
    Assert.assertNull(childGlobalNS.getNamespaceURI());
    Assert.assertEquals(childDefaultNS.getNamespaceURI(), TEST_NS);
}
 
Example 17
Source File: CompilatioAPIUtil.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
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 vote down vote up
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: SignCodeMojo.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
private String makeSigningRequest(SignedFiles signedFiles) throws SOAPException, IOException, MojoExecutionException {
    log("Constructing the code signing request");

    SOAPMessage message = SOAP_MSG_FACTORY.createMessage();
    SOAPBody body = populateEnvelope(message, NS);

    SOAPElement requestSigning = body.addChildElement("requestSigning", NS);
    SOAPElement requestSigningRequest =
            requestSigning.addChildElement("requestSigningRequest", NS);

    addCredentials(requestSigningRequest, this.userName, this.password, this.partnerCode);

    SOAPElement applicationName =
            requestSigningRequest.addChildElement("applicationName", NS);
    applicationName.addTextNode(this.applicationName);

    SOAPElement applicationVersion =
            requestSigningRequest.addChildElement("applicationVersion", NS);
    applicationVersion.addTextNode(this.applicationVersion);

    SOAPElement signingServiceName =
            requestSigningRequest.addChildElement("signingServiceName", NS);
    signingServiceName.addTextNode(this.signingService);

    SOAPElement commaDelimitedFileNames =
            requestSigningRequest.addChildElement("commaDelimitedFileNames", NS);
    commaDelimitedFileNames.addTextNode(signedFiles.getCommaSeparatedUploadFileNames());

    SOAPElement application =
            requestSigningRequest.addChildElement("application", NS);
    application.addTextNode(signedFiles.getApplicationString());

    // Send the message
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection connection = soapConnectionFactory.createConnection();

    log("Sending signing request to server and waiting for response");
    SOAPMessage response = connection.call(message, SIGNING_SERVICE_URL);

    if ( getLog().isDebugEnabled()) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream(2 * 1024);
        response.writeTo(baos);
        getLog().debug(baos.toString("UTF-8"));
    }

    log("Processing response");
    SOAPElement responseBody = response.getSOAPBody();

    // Should come back signed
    NodeList bodyNodes = responseBody.getChildNodes();
    NodeList requestSigningResponseNodes = bodyNodes.item(0).getChildNodes();
    NodeList returnNodes = requestSigningResponseNodes.item(0).getChildNodes();

    String signingSetID = null;
    String signingSetStatus = null;
    StringBuilder errors = new StringBuilder();

    for (int i = 0; i < returnNodes.getLength(); i++) {
        Node returnNode = returnNodes.item(i);
        if (returnNode.getLocalName().equals("signingSetID")) {
            signingSetID = returnNode.getTextContent();
        } else if (returnNode.getLocalName().equals("signingSetStatus")) {
            signingSetStatus = returnNode.getTextContent();
        } else if (returnNode.getLocalName().equals("result") ) {
            final NodeList returnChildNodes = returnNode.getChildNodes();
            for (int j = 0; j < returnChildNodes.getLength(); j++ ) {
                if ( returnChildNodes.item(j).getLocalName().equals("errors") ) {
                    extractErrors(returnChildNodes.item(j), errors);
                }
            }
        }
    }

    if (!signingService.contains("TEST") && !"SIGNED".equals(signingSetStatus) ||
            signingService.contains("TEST") && !"INITIALIZED".equals(signingSetStatus) ) {
        throw new BuildException("Signing failed. Status was: " + signingSetStatus + " . Reported errors: " + errors + ".");
    }

    return signingSetID;
}
 
Example 20
Source File: SOAPGenerator.java    From cougar with Apache License 2.0 3 votes vote down vote up
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;
	
}