Examples of SOAPFaultCode


Examples of org.apache.axiom.soap.SOAPFaultCode

    if (soapFault == null) {
      return false;
    }

    String soapVersionURI = rmd.getMsgContext().getEnvelope().getNamespace().getNamespaceURI();
    SOAPFaultCode faultCode = soapFault.getCode();
    if(faultCode == null){
      //If no fault code is given, then it can't be security fault
      return false;
    }
   
    if (soapVersionURI.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
      // This is a fault processing the security header
      if (faultCode.getTextAsQName().getNamespaceURI().equals(WSConstants.WSSE_NS)) {
        return true;
      }
    } else if (soapVersionURI.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
      // TODO AXIOM API returns only one fault sub code, there can be many
      SOAPFaultSubCode faultSubCode = faultCode.getSubCode();
      if (faultSubCode != null) {
        SOAPFaultValue faultSubCodeValue = faultSubCode.getValue();

        // This is a fault processing the security header
        if (faultSubCodeValue != null && faultSubCodeValue.getTextAsQName().
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(faultMsgEnvelope));

    SOAPFault fault = faultMsgEnvelope.getBody().getFault();
    SOAPFaultCode faultCode = fault.getCode();

    if (isSequenceFault(data)) {
      faultCode.setText(data.getCode());
    } else {
      faultCode.setText(data.getSubcode());
    }

    SOAPFaultReason faultReason = fault.getReason();

    OMNamespace namespace = factory.createOMNamespace(
        OMConstants.XMLNS_URI, OMConstants.XMLNS_PREFIX);
    faultReason.getSOAPFaultText("en").addAttribute("lang", "en", namespace);

    faultReason.setText(data.getReason());
    faultCode.getValue().setText(data.getSubcode());
    SOAPFaultText faultText = faultReason.getSOAPFaultText("en");
    if (faultText==null)
      faultText = factory.createSOAPFaultText();
   
    faultText.setText(data.getReason());
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

    SOAPFault fault = faultEnvelope.getBody().getFault();
    if (fault == null)
      throw new SandeshaException("Fault part is null");

    SOAPFaultCode faultCode = fault.getCode();
    SOAPFaultValue codeValue = faultCode.getValue();
    codeValue.setText(data.getCode());

    SOAPFaultSubCode faultSubCode = factory
        .createSOAPFaultSubCode(faultCode);
    SOAPFaultValue subCodeValue = factory
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(faultMsgEnvelope));

    SOAPFault fault = faultMsgEnvelope.getBody().getFault();

        SOAPFaultCode code = fault.getCode();
        if (data.getCode()!=null) {
            code.setText(data.getCode());
        }

        if (data.getExceptionString() != null)
      fault.getDetail().setText(data.getExceptionString());
   
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

    if (fault == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.noFaultCode,
          faultEnvelope.toString()));

    SOAPFaultCode faultCode = fault.getCode();
    SOAPFaultValue codeValue = faultCode.getValue();
    codeValue.setText(data.getCode());

    SOAPFaultSubCode faultSubCode = factory
        .createSOAPFaultSubCode(faultCode);
    SOAPFaultValue subCodeValue = factory
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

        HttpServletResponse response =
                (HttpServletResponse) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
        if (response != null) {

            //TODO : Check for SOAP 1.2!
            SOAPFaultCode code = faultContext.getEnvelope().getBody().getFault().getCode();

            OMElement valueElement = null;
            if (code != null) {
                valueElement = code.getFirstChildWithName(new QName(
                        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
                        SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
            }

            if (valueElement != null) {
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

            AxisEngine.send(outMsgContext);
    }

        private SOAPFault toSoapFault(Exception e, SOAPFactory soapFactory) {
        SOAPFault fault = soapFactory.createSOAPFault();
        SOAPFaultCode code = soapFactory.createSOAPFaultCode(fault);
        code.setText(new QName(Namespaces.SOAP_ENV_NS, "Server"));
        SOAPFaultReason reason = soapFactory.createSOAPFaultReason(fault);
        reason.setText(e.toString());

            OMElement detail = soapFactory
                    .createOMElement(new QName(Namespaces.ODE_PMAPI, e.getClass().getSimpleName()));
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

    public SOAPFault createSoapFault(Element message, QName faultName, Operation op) throws AxisFault {
        OMElement detail = buildSoapDetail(message, faultName, op);

        SOAPFault fault = _soapFactory.createSOAPFault();
        SOAPFaultCode code = _soapFactory.createSOAPFaultCode(fault);
        code.setText(new QName(Namespaces.SOAP_ENV_NS, "Server"));
        SOAPFaultReason reason = _soapFactory.createSOAPFaultReason(fault);
        reason.setText(faultName);
        SOAPFaultDetail soapDetail = _soapFactory.createSOAPFaultDetail(fault);
        if (detail != null)
            soapDetail.addDetailEntry(detail);
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

        if (elementLevel == 4) {

            if (SOAP_FAULT_CODE_LOCAL_NAME.equals(localName)) {

                SOAPFaultCode code = factory.createSOAPFaultCode(
                        (SOAPFault) parent, builder);
                SOAPFaultValue value = factory.createSOAPFaultValue(code);
                processNamespaceData(code, false);
                processAttributes(code);
View Full Code Here

Examples of org.apache.axiom.soap.SOAPFaultCode

                            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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().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.internalSerializeAndConsume(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().getNamespaceURI().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().getNamespaceURI().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().getNamespaceURI().equals(
                            "http://example.org/ts-tests"));
            assertTrue("SOAP 1.1 :- Headaer block text mismatch",
                    headerBlock.getText().trim().equals("foo"));

            // Attribute iteration is not in any guaranteed order.
            // Use QNames to get the OMAttributes.
            QName actorQName = new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, SOAP11Constants.ATTR_ACTOR);
            mustUnderstandQName = new QName(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, SOAP11Constants.ATTR_MUSTUNDERSTAND);

            OMAttribute actorAttribute = headerBlock.getAttribute(actorQName);
            mustUnderstandAttribute = headerBlock.getAttribute(mustUnderstandQName);

            assertTrue("SOAP 1.1 :- Mustunderstand attribute not found",
                    mustUnderstandAttribute != null);
            assertTrue("SOAP 1.1 :- Mustunderstand value mismatch",
                    mustUnderstandAttribute.getAttributeValue().equals(
                            SOAPConstants.ATTR_MUSTUNDERSTAND_1));
            assertTrue(
                    "SOAP 1.1 :- Mustunderstand attribute namespace uri mismatch",
                    mustUnderstandAttribute.getNamespace().getNamespaceURI().equals(
                            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            assertTrue("SOAP 1.1 :- Actor attribute name not found",
                    actorAttribute != null);
            assertTrue("SOAP 1.1 :- Actor value mismatch",
                    actorAttribute.getAttributeValue().trim().equals(
                            "http://schemas.xmlsoap.org/soap/" +
                                    SOAP11Constants.ATTR_ACTOR +
                                    "/" +
                                    "next"));
            assertTrue("SOAP 1.1 :- Actor attribute namespace uri mismatch",
                    actorAttribute.getNamespace().getNamespaceURI().equals(
                            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            body = soap11Envelope.getBody();
            assertTrue("SOAP 1.1 :- Body local name mismatch",
                    body.getLocalName().equals(SOAPConstants.BODY_LOCAL_NAME));
            assertTrue("SOAP 1.1 :- Body namespace uri mismatch",
                    body.getNamespace().getNamespaceURI().equals(
                            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            fault = body.getFault();
            assertTrue("SOAP 1.1 :- Fault namespace uri mismatch",
                    fault.getNamespace().getNamespaceURI().equals(
                            SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI));

            iteratorInFault = fault.getChildren();

            iteratorInFault.next();
            code = (SOAPFaultCode) iteratorInFault.next();
            assertEquals("SOAP Fault code local name mismatch",
                    code.getLocalName(),
                    (SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME));

            assertEquals("SOAP 1.1 :- Fault code value mismatch", code.getValue().getText().trim(),
                    "env:Sender");

            iteratorInFault.next();
            reason = (SOAPFaultReason) iteratorInFault.next();
            assertTrue("SOAP 1.1 :- Fault string local name mismatch",
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.