Package org.apache.axis2.soap

Examples of org.apache.axis2.soap.SOAPHeaderBlock


        reqEnv.declareNamespace("http://soapinterop.org", "m1");
        reqEnv.declareNamespace("http://schemas.xmlsoap.org/wsdl/soap12/", "soap12");

        SOAPHeader header = omfactory.createSOAPHeader(reqEnv);
        OMNamespace hns = reqEnv.declareNamespace("http://soapinterop.org/echoheader/", "hns"); //xmlns:m0="http://soapinterop.org/echoheader/
        SOAPHeaderBlock block1 = header.addHeaderBlock("echoMeStringRequest", hns);
        block1.addAttribute("xsi:type", "xsd:string", null);
        block1.addChild(omfactory.createText("string"));
        // header.addChild(headerChild);
        header.addChild(block1);

        SOAPHeaderBlock block2 = header.addHeaderBlock("echoMeStructRequest", hns);
        block2.addAttribute("xsi:type", "s:SOAPStruct", null);

        OMElement h2Val1 = omfactory.createOMElement("varString", null);
        h2Val1.addAttribute("xsi:type", "xsd:string", null);
        h2Val1.addChild(omfactory.createText("string"));

        OMElement h2Val2 = omfactory.createOMElement("varInt", null);
        h2Val2.addAttribute("xsi:type", "xsd:int", null);
        h2Val2.addChild(omfactory.createText("150"));

        OMElement h2Val3 = omfactory.createOMElement("varFloat", null);
        h2Val3.addAttribute("xsi:type", "xsd:float", null);
        h2Val3.addChild(omfactory.createText("456.321"));

        block2.addChild(h2Val1);
        block2.addChild(h2Val2);
        block2.addChild(h2Val3);

        OMElement operation = omfactory.createOMElement("echoStringArray", "http://soapinterop.org/", null);
        SOAPBody body = omfactory.createSOAPBody(reqEnv);
        body.addChild(operation);
        operation.addAttribute("soapenv:encodingStyle", "http://www.w3.org/2003/05/soap-encoding", null);
View Full Code Here


//        block1.addAttribute("xsi:type", "xsd:string", null);
//        block1.addChild(omfactory.createText("string"));
//        // header.addChild(headerChild);
//        header.addChild(block1);  m0:echoMeStructRequest xsi:type="m1:echoMeStructRequest

        SOAPHeaderBlock block2 = header.addHeaderBlock("echoMeStructRequest", ns1);
        block2.addAttribute("xsi:type", "hns:echoMeStructRequest", null);

        OMElement h2Val1 = omfactory.createOMElement("varString", null);
        h2Val1.addAttribute("xsi:type", "xsd:string", null);
        h2Val1.addChild(omfactory.createText("string"));

        OMElement h2Val2 = omfactory.createOMElement("varInt", null);
        h2Val2.addAttribute("xsi:type", "xsd:int", null);
        h2Val2.addChild(omfactory.createText("150"));

        OMElement h2Val3 = omfactory.createOMElement("varFloat", null);
        h2Val3.addAttribute("xsi:type", "xsd:float", null);
        h2Val3.addChild(omfactory.createText("456.321"));

        block2.addChild(h2Val1);
        block2.addChild(h2Val2);
        block2.addChild(h2Val3);

        OMElement operation = omfactory.createOMElement("echoVoid", "http://soapinterop.org/", null);
        SOAPBody body = omfactory.createSOAPBody(reqEnv);
        body.addChild(operation);
        operation.addAttribute("soapenv:encodingStyle", "http://www.w3.org/2003/05/soap-encoding", null);
View Full Code Here

        reqEnv.declareNamespace("http://soapinterop.org", "m1");
        reqEnv.declareNamespace("http://schemas.xmlsoap.org/wsdl/soap12/", "soap12");

        SOAPHeader header = omfactory.createSOAPHeader(reqEnv);
        OMNamespace hns = reqEnv.declareNamespace("http://soapinterop.org/echoheader/", "hns"); //xmlns:m0="http://soapinterop.org/echoheader/
        SOAPHeaderBlock block1 = header.addHeaderBlock("echoMeStringRequest", hns);
        block1.addAttribute("xsi:type", "xsd:string", null);
        block1.addChild(omfactory.createText("string"));
        // header.addChild(headerChild);
        header.addChild(block1);

        SOAPHeaderBlock block2 = header.addHeaderBlock("echoMeStructRequest", hns);
        block2.addAttribute("xsi:type", "s:SOAPStruct", null);

        OMElement h2Val1 = omfactory.createOMElement("varString", null);
        h2Val1.addAttribute("xsi:type", "xsd:string", null);
        h2Val1.addChild(omfactory.createText("string"));

        OMElement h2Val2 = omfactory.createOMElement("varInt", null);
        h2Val2.addAttribute("xsi:type", "xsd:int", null);
        h2Val2.addChild(omfactory.createText("150"));

        OMElement h2Val3 = omfactory.createOMElement("varFloat", null);
        h2Val3.addAttribute("xsi:type", "xsd:float", null);
        h2Val3.addChild(omfactory.createText("456.321"));

        block2.addChild(h2Val1);
        block2.addChild(h2Val2);
        block2.addChild(h2Val3);

        OMElement operation = omfactory.createOMElement("echoFloatArray", "http://soapinterop.org/", null);
        SOAPBody body = omfactory.createSOAPBody(reqEnv);
        body.addChild(operation);
        operation.addAttribute("soapenv:encodingStyle", "http://www.w3.org/2003/05/soap-encoding", null);
View Full Code Here

        Integer headerBlockPresent = (Integer) msgContext.getOperationContext().getProperty("HEADER_BLOCK_PRESENT", true);
        if (headerBlockPresent.equals(new Integer(1))) {
            SOAPHeader headerAdd = (SOAPHeader) msgContext.getOperationContext().getProperty("HEADER_BLOCK", true);
           Iterator headerBlocks = headerAdd.examineAllHeaderBlocks();
            while(headerBlocks.hasNext()){
                SOAPHeaderBlock headerBlock=(SOAPHeaderBlock) headerBlocks.next();
                msgContext.getEnvelope().getHeader().addChild(headerBlock);
            }
        } else {
            msgContext.getEnvelope().getHeader().discard();
        }
View Full Code Here

        Integer headerBlockPresent = (Integer) msgContext.getOperationContext().getProperty("HEADER_BLOCK_PRESENT", true);
        if (headerBlockPresent.equals(new Integer(1))) {
            SOAPHeader headerAdd = (SOAPHeader) msgContext.getOperationContext().getProperty("HEADER_BLOCK", true);
           Iterator headerBlocks = headerAdd.examineAllHeaderBlocks();
            while(headerBlocks.hasNext()){
                SOAPHeaderBlock headerBlock=(SOAPHeaderBlock) headerBlocks.next();
                msgContext.getEnvelope().getHeader().addChild(headerBlock);
            }
        } else {
            msgContext.getEnvelope().getHeader().discard();
        }
View Full Code Here

                        ex);
      }
     
      Iterator headers = header.examineHeaderBlocks(actor);
     
      SOAPHeaderBlock headerBlock = null;
     
      while(headers.hasNext()) { //Find the wsse header
        SOAPHeaderBlock hb = (SOAPHeaderBlock)headers.next();
                if (hb.getLocalName().equals(WSConstants.WSSE_LN)
                        && hb.getNamespace().getName().equals(WSConstants.WSSE_NS)) {
                    headerBlock = hb;
                    break;
                }
      }
           
View Full Code Here

      }
       
        while (headerBlocksIter.hasNext()) {
            Object o = headerBlocksIter.next();
            if (o instanceof SOAPHeaderBlock) {
                SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) o;
                String role = soapHeaderBlock.getRole();
                if ((role != null) && role.equalsIgnoreCase(paramRole)) {
                    headersWithGivenActor.add(soapHeaderBlock);
                }
            }
        }
View Full Code Here

        Iterator headerBlocksIter = this.getChildren();
        ArrayList mustUnderstandHeadersWithGivenActor = new ArrayList();
        while (headerBlocksIter.hasNext()) {
            Object o = headerBlocksIter.next();
            if (o instanceof SOAPHeaderBlock) {
                SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) o;
                String role = soapHeaderBlock.getRole();
                boolean mustUnderstand = soapHeaderBlock.getMustUnderstand();
                if ((role != null) && role.equalsIgnoreCase(actor) &&
                        mustUnderstand) {
                    mustUnderstandHeadersWithGivenActor.add(soapHeaderBlock);
                }
            }
View Full Code Here

        OMNamespace namespace = findNamespace(ns.getName(), ns.getPrefix());
        if (namespace != null) {
            ns = namespace;
        }

        SOAPHeaderBlock soapHeaderBlock = null;
        try {
            soapHeaderBlock = new SOAP12HeaderBlockImpl(localName, ns, this);
        } catch (SOAPProcessingException e) {
            throw new OMException(e);
        }
View Full Code Here

                            SOAPConstants.HEADER_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Header namespace uri mismatch",
                    header.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) header.getFirstElement();
            assertTrue("SOAP 1.2 :- Header block name mismatch",
                    headerBlock.getLocalName().equals("echoOk"));
            assertTrue("SOAP 1.2 :- Header block name space uri mismatch",
                    headerBlock.getNamespace().getName().equals(
                            "http://example.org/ts-tests"));
            assertEquals("SOAP 1.2 :- Header block text mismatch",headerBlock.getText().trim(),"foo");

            Iterator headerBlockAttributes = headerBlock.getAllAttributes();
            OMAttribute roleAttribute = (OMAttribute) headerBlockAttributes.next();
            assertTrue("SOAP 1.2 :- Role attribute name mismatch",
                    roleAttribute.getLocalName().equals(
                            SOAP12Constants.SOAP_ROLE));
           

            assertTrue("SOAP 1.2 :- Role value mismatch",
                    roleAttribute.getAttributeValue().trim().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI + "/" +
                    SOAP12Constants.SOAP_ROLE +
                    "/" +
                    "ultimateReceiver"));
            assertTrue("SOAP 1.2 :- Role attribute namespace uri mismatch",
                    roleAttribute.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            OMAttribute mustUnderstandAttribute = (OMAttribute) headerBlockAttributes.next();
            assertTrue("SOAP 1.2 :- Mustunderstand attribute name mismatch",
                    mustUnderstandAttribute.getLocalName().equals(
                            SOAPConstants.ATTR_MUSTUNDERSTAND));
            assertTrue("SOAP 1.2 :- Mustunderstand value mismatch",
                    mustUnderstandAttribute.getAttributeValue().equals(
                            SOAPConstants.ATTR_MUSTUNDERSTAND_TRUE));
            assertTrue(
                    "SOAP 1.2 :- Mustunderstand attribute namespace uri mismatch",
                    mustUnderstandAttribute.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            SOAPBody body = soap12Envelope.getBody();
            assertTrue("SOAP 1.2 :- Body local name mismatch",
                    body.getLocalName().equals(SOAPConstants.BODY_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Body namespace uri mismatch",
                    body.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            SOAPFault fault = body.getFault();
            assertTrue("SOAP 1.2 :- Fault local name mismatch",
                    fault.getLocalName().equals(
                            SOAPConstants.SOAPFAULT_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault namespace uri mismatch",
                    fault.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            Iterator iteratorInFault = fault.getChildren();

            iteratorInFault.next();
            SOAPFaultCode code = (SOAPFaultCode) iteratorInFault.next();
            assertTrue("SOAP 1.2 :- Fault code local name mismatch",
                    code.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault code namespace uri mismatch",
                    code.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            Iterator iteratorInCode = code.getChildren();

            iteratorInCode.next();
            SOAPFaultValue value1 = (SOAPFaultValue) iteratorInCode.next();
            assertTrue("SOAP 1.2 :- Fault code value local name mismatch",
                    value1.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault code namespace uri mismatch",
                    value1.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));
            assertTrue("SOAP 1.2 :- Value1 text mismatch",
                    value1.getText().equals("env:Sender"));

            iteratorInCode.next();
            SOAPFaultSubCode subCode1 = (SOAPFaultSubCode) iteratorInCode.next();
            assertTrue("SOAP 1.2 :- Fault sub code local name mismatch",
                    subCode1.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault subcode namespace uri mismatch",
                    subCode1.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            Iterator iteratorInSubCode1 = subCode1.getChildren();

            iteratorInSubCode1.next();
            SOAPFaultValue value2 = (SOAPFaultValue) iteratorInSubCode1.next();
            assertTrue("SOAP 1.2 :- Fault code value local name mismatch",
                    value2.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault code namespace uri mismatch",
                    value2.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));
            assertTrue("SOAP 1.2 :- Value2 text mismatch",
                    value2.getText().equals("m:MessageTimeout"));

            iteratorInSubCode1.next();
            SOAPFaultSubCode subCode2 = (SOAPFaultSubCode) iteratorInSubCode1.next();
            assertTrue("SOAP 1.2 :- Fault sub code local name mismatch",
                    subCode2.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault subcode namespace uri mismatch",
                    subCode2.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            Iterator iteratorInSubCode2 = subCode2.getChildren();

            iteratorInSubCode2.next();
            SOAPFaultValue value3 = (SOAPFaultValue) iteratorInSubCode2.next();
            assertTrue("SOAP 1.2 :- Fault code value local name mismatch",
                    value3.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault code namespace uri mismatch",
                    value3.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));
            assertTrue("SOAP 1.2 :- Value2 text mismatch",
                    value3.getText().equals("m:MessageTimeout"));

            iteratorInFault.next();
            SOAPFaultReason reason = (SOAPFaultReason) iteratorInFault.next();
            assertTrue("SOAP 1.2 :- Fault reason local name mismatch",
                    reason.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault reason namespace uri mismatch",
                    reason.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            Iterator iteratorInReason = reason.getChildren();

            iteratorInReason.next();
            SOAPFaultText text = (SOAPFaultText) iteratorInReason.next();
            assertTrue("SOAP 1.2 :- Fault text local name mismatch",
                    text.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_TEXT_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Text namespace uri mismatch",
                    text.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));
            assertTrue("SOAP 1.2 :- Text value mismatch",
                    text.getText().equals("Sender Timeout"));

            iteratorInFault.next();
            SOAPFaultNode node = (SOAPFaultNode) iteratorInFault.next();
            assertTrue("SOAP 1.2 :- Fault node local name mismatch",
                    node.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault node namespace uri mismatch",
                    node.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));
            assertTrue("SOAP 1.2 :- Node value mismatch",
                    node.getText().trim().equals(
                            "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver"));

            iteratorInFault.next();
            SOAPFaultRole role = (SOAPFaultRole) iteratorInFault.next();
            assertTrue("SOAP 1.2 :- Fault role local name mismatch",
                    role.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault role namespace uri mismatch",
                    role.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));
            assertTrue("SOAP 1.2 :- Role value mismatch",
                    role.getText().trim().equals("ultimateReceiver"));

            iteratorInFault.next();
            SOAPFaultDetail detail = (SOAPFaultDetail) iteratorInFault.next();
            assertTrue("SOAP 1.2 :- Fault detail local name mismatch",
                    detail.getLocalName().equals(
                            SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME));
            assertTrue("SOAP 1.2 :- Fault detail namespace uri mismatch",
                    detail.getNamespace().getName().equals(
                            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            assertTrue("SOAP 1.2 :- Text in detail mismatch",
                    detail.getText().trim().equals("Details of error"));

            Iterator iteratorInDetail = detail.getChildren();

            iteratorInDetail.next();
            OMElement element1 = (OMElement) iteratorInDetail.next();
            assertTrue("SOAP 1.2 :- MaxTime element mismatch",
                    element1.getLocalName().equals("MaxTime"));
            assertTrue("SOAP 1.2 :- MaxTime element namespace mismatch",
                    element1.getNamespace().getName().equals(
                            "http:www.sample.org"));
            assertTrue("SOAP 1.2 :- Text value in MaxTime element mismatch",
                    element1.getText().trim().equals("P5M"));

            Iterator attributeIterator = element1.getAllAttributes();
            OMAttribute attributeInMaxTime = (OMAttribute) attributeIterator.next();
            assertTrue("SOAP 1.2 :- Attribute local name mismatch",
                    attributeInMaxTime.getLocalName().equals("detail"));
            assertTrue("SOAP 1.2 :- Attribute namespace mismatch",
                    attributeInMaxTime.getNamespace().getName().equals(
                            "http:www.sample.org"));
            assertTrue("SOAP 1.2 :- Attribute value mismatch",
                    attributeInMaxTime.getAttributeValue().trim().equals("This is only a test"));

            iteratorInDetail.next();
            OMElement element2 = (OMElement) iteratorInDetail.next();
            assertTrue("SOAP 1.2 :- AveTime element mismatch",
                    element2.getLocalName().equals("AveTime"));
            assertTrue("SOAP 1.2 :- AveTime element namespace mismatch",
                    element2.getNamespace().getName().equals(
                            "http:www.sample.org"));

            Iterator iteratorInAveTimeElement = element2.getChildren();

            iteratorInAveTimeElement.next();
            OMElement element21 = (OMElement) iteratorInAveTimeElement.next();
            assertTrue("SOAP 1.2 :- Time element mismatch",
                    element21.getLocalName().equals("Time"));
            assertTrue("SOAP 1.2 :- Time element namespace mismatch",
                    element21.getNamespace().getName().equals(
                            "http:www.sample.org"));
            assertTrue("SOAP 1.2 :- Text value in Time element mismatch",
                    element21.getText().trim().equals("P3M"));

            XMLStreamReader sopa11Parser = XMLInputFactory.newInstance()
                    .createXMLStreamReader(new StringReader(soap11Message));
            OMXMLParserWrapper soap11Builder = new StAXSOAPModelBuilder(sopa11Parser, null);
            SOAPEnvelope soap11Envelope = (SOAPEnvelope) soap11Builder.getDocumentElement();
//            soap11Envelope.build();
//            writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
//            soap11Envelope.serializeAndConsume(writer);
//        writer.flush();

            assertTrue("SOAP 1.1 :- envelope local name mismatch",
                    soap11Envelope.getLocalName().equals(
                            SOAPConstants.SOAPENVELOPE_LOCAL_NAME));
            assertTrue("SOAP 1.1 :- envelope namespace uri mismatch",
                    soap11Envelope.getNamespace().getName().equals(
                            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            header = soap11Envelope.getHeader();
            assertTrue("SOAP 1.1 :- Header local name mismatch",
                    header.getLocalName().equals(
                            SOAPConstants.HEADER_LOCAL_NAME));
            assertTrue("SOAP 1.1 :- Header namespace uri mismatch",
                    header.getNamespace().getName().equals(
                            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            headerBlock = (SOAPHeaderBlock) header.getFirstElement();
            assertTrue("SOAP 1.1 :- Header block name mismatch",
                    headerBlock.getLocalName().equals("echoOk"));
            assertTrue("SOAP 1.1 :- Header block name space uri mismatch",
                    headerBlock.getNamespace().getName().equals(
                            "http://example.org/ts-tests"));
            assertTrue("SOAP 1.1 :- Headaer block text mismatch",
                    headerBlock.getText().trim().equals("foo"));

            headerBlockAttributes = headerBlock.getAllAttributes();

            mustUnderstandAttribute =
                    (OMAttribute) headerBlockAttributes.next();
            assertTrue("SOAP 1.1 :- Mustunderstand attribute name mismatch",
                    mustUnderstandAttribute.getLocalName().equals(
View Full Code Here

TOP

Related Classes of org.apache.axis2.soap.SOAPHeaderBlock

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.