Package org.apache.ws.commons.soap

Examples of org.apache.ws.commons.soap.SOAPEnvelope


    public void testGetText() {
        try {
            StAXSOAPModelBuilder soapBuilder = getOMBuilder(
                    "soap/OMElementTest.xml");
            SOAPEnvelope soapEnvelope = (SOAPEnvelope) soapBuilder.getDocumentElement();
            OMElement wsaTo = soapEnvelope.getHeader().getFirstChildWithName(
                    new QName(WSA_URI, WSA_TO));

            String expectedString = "http://localhost:8081/axis/services/BankPort";
            assertEquals("getText is not returning the correct value",
                    wsaTo.getText().trim(),
View Full Code Here


  }
 
  public void runTest(String value, String expected) throws XMLStreamException, FactoryConfigurationError, IOException {
   
    SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    String ns = "http://testuri.org";
    OMNamespace namespace = factory.createOMNamespace(ns,"tst");
   
    String ln = "Child";
   
    OMElement bodyChild = factory.createOMElement(ln,namespace);
    bodyChild.addChild(factory.createText(value));
   
    envelope.getBody().addChild(bodyChild);


    ByteArrayOutputStream byteOutStr = new ByteArrayOutputStream();
   
    OMOutputFormat outputFormat = new OMOutputFormat();
        outputFormat.setCharSetEncoding(UTF_16);
    envelope.serialize(byteOutStr, outputFormat);
   
    ByteArrayInputStream byteInStr = new ByteArrayInputStream(byteOutStr.toByteArray());
   
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(XMLInputFactory.newInstance().createXMLStreamReader(byteInStr, UTF_16),null);

    SOAPEnvelope resultEnv = builder.getSOAPEnvelope();
   
    OMElement bodyChildResult = resultEnv.getBody().getFirstElement();
   
    assertNotNull("No child in body element", bodyChildResult);
   
    String result = bodyChildResult.getText();
   
View Full Code Here

    public void testCreateSOAPBody() {
        try {
            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
                    getTestResourceFile("soap/minimalMessage.xml"));
            SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
            SOAPBody soapBodyOne = omFactory.createSOAPBody(soapEnvelope);
            assertTrue(
                    "Programatically created SOAPBody should have done = true ",
                    soapBodyOne.isComplete());
            soapBodyOne.detach();
View Full Code Here

    public void testCreateSOAPEnvelope() {
        try {
            omFactory.createOMNamespace(
                    SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
                    SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX);
            SOAPEnvelope soapEnvelopeTwo = omFactory.createSOAPEnvelope();
            assertTrue(
                    "Programatically created SOAPEnvelope should have done = true ",
                    soapEnvelopeTwo.isComplete());
            SOAPEnvelope soapEnvelope = omFactory.createSOAPEnvelope(
                    OMTestUtils.getOMBuilder(
                            getTestResourceFile("soap/minimalMessage.xml")));
            assertTrue(
                    "SOAPEnvelope with a builder should start with done = false ",
                    !soapEnvelope.isComplete());
            assertTrue("This SOAPEnvelope must have a builder ",
                    soapEnvelope.getBuilder() instanceof OMXMLParserWrapper);


        } catch (Exception e) {
            log.info(e.getMessage());
        }
View Full Code Here

    public void testCreateSOAPHeader() {
        try {
            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
                    getTestResourceFile("soap/minimalMessage.xml"));
            SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
            SOAPHeader soapHeader = omFactory.createSOAPHeader(soapEnvelope);
            assertTrue(
                    "Programatically created SOAPHeader should have done = true ",
                    soapHeader.isComplete());
            soapHeader.detach();
View Full Code Here

    public void testCreateSOAPHeaderBlock() {
        try {
            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
                    getTestResourceFile("soap/soapmessage.xml"));
            SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
            SOAPHeader soapHeader = soapEnvelope.getHeader();
            SOAPHeaderBlock soapHeaderBlock = omFactory.createSOAPHeaderBlock(
                    "soapHeaderBlockOne", namespace, soapHeader);
            assertTrue(
                    "Programatically created SOAPHeaderBlock should have done = true ",
                    soapHeaderBlock.isComplete());
View Full Code Here

    public void testCreateSOAPFault() {
        try {
            OMXMLParserWrapper omBuilder = OMTestUtils.getOMBuilder(
                    getTestResourceFile("soap/soapmessage.xml"));
            SOAPEnvelope soapEnvelope = (SOAPEnvelope) omBuilder.getDocumentElement();
            SOAPBody soapBody = soapEnvelope.getBody();
            SOAPFault soapFault = omFactory.createSOAPFault(soapBody,
                    new Exception(" this is just a test "));
            assertTrue(
                    "Programatically created SOAPFault should have done = true ",
                    soapFault.isComplete());
View Full Code Here

     *
     * @param result
     */
    private void extractDetails(AsyncResult result) {
        Iterator iterator0, iterator1, iterator2, iterator3, iterator4;
        SOAPEnvelope resEnvilop;
        OMElement body;
        OMElement operation;
        OMNode node;
        OMElement elem;

        resEnvilop = result.getResponseEnvelope();
        body = resEnvilop.getBody();
        operation = body.getFirstElement();

        String opLocalName = operation.getLocalName();
        if (opLocalName.equals("Fault")) {
            log.info(
View Full Code Here

        OMNamespace namespace, nulNS;
        OMElement operation, value1, value2;
        OMElement subValue1, subValue2, subValue3, subValue4, subValue5;

        SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope reqEnv = omFactory.getDefaultEnvelope();
        namespace = reqEnv.declareNamespace(
                "http://schemas.xmlsoap.org/soap/envelope/",
                "SOAP-ENV");
        namespace = reqEnv.declareNamespace(
                "http://schemas.xmlsoap.org/soap/encoding/",
                "SOAP-ENC");
        namespace =
                reqEnv.declareNamespace(
                        "http://www.w3.org/1999/XMLSchema-instance/", "xsi");
        namespace =
                reqEnv.declareNamespace("http://www.w3.org/2001/XMLSchema",
                        "xsd");
        namespace = reqEnv.declareNamespace(
                "http://schemas.xmlsoap.org/wsdl/soap/",
                "soap");
        namespace = reqEnv.declareNamespace("http://schemas.xmlsoap.org/wsdl/",
                "wsdl");
        namespace = reqEnv.declareNamespace(
                "http://webservices.amazon.com/AWSAlexa/2005-02-01",
                "tns");

        nulNS = omFactory.createOMNamespace("", "");

        operation =
                omFactory.createOMElement("Search",
                        "http://webservices.amazon.com/AWSAlexa/2005-02-01",
                        "ns1");
        reqEnv.getBody().addChild(operation);
        operation.addAttribute("encordingStyle",
                "http://schemas.xmlsoap.org/soap/encoding/",
                null);

View Full Code Here

        } else if (args[0].equals("-I")) {
            options.setAction(intersectActionString);
        }

        SOAPEnvelope env = OMAbstractFactory.getSOAP11Factory()
                .getDefaultEnvelope();

        // adding args[1]
        env.getBody().addChild(getOMElementFromURL(args[1]));

        if (!args[0].equals("-N")) {
            env.getBody().addChild(getOMElementFromURL(args[2]));
        }

        SOAPEnvelope response = (SOAPEnvelope) call.invokeBlocking("foo", env);

        StringWriter sw = new StringWriter();
        OMElement result = response.getBody().getFirstElement();

        System.out.println("Output");
        result.serialize(XMLOutputFactory.newInstance().createXMLStreamWriter(
                sw));
        sw.flush();
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.soap.SOAPEnvelope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.