Search in sources :

Example 6 with SOAPFaultText

use of org.apache.axiom.soap.SOAPFaultText in project webservices-axiom by apache.

the class TestGetFaultReasonTextCaseSensitivity method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFaultReason reason = soapFactory.createSOAPFaultReason();
    SOAPFaultText text = soapFactory.createSOAPFaultText(reason);
    text.setLang("EN-US");
    text.setText("Some reason");
    assertThat(reason.getFaultReasonText(Locale.ENGLISH)).isEqualTo("Some reason");
}
Also used : SOAPFaultReason(org.apache.axiom.soap.SOAPFaultReason) SOAPFaultText(org.apache.axiom.soap.SOAPFaultText)

Example 7 with SOAPFaultText

use of org.apache.axiom.soap.SOAPFaultText in project webservices-axiom by apache.

the class TestGetLangWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPFaultText faultText = envelope.getBody().getFault().getReason().getFirstSOAPText();
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - getLang method returns incorrect string", faultText.getLang().equals("en"));
    OMAttribute langAttribute = faultText.getAllAttributes().next();
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute local name mismaatch", langAttribute.getLocalName().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME));
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace prefix mismatch", langAttribute.getNamespace().getPrefix().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_PREFIX));
    assertTrue("SOAP 1.2 Fault Text Test With Parser : - Lang attribute namespace uri mismatch", langAttribute.getNamespace().getNamespaceURI().equals(SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_NS_URI));
}
Also used : SOAPFaultText(org.apache.axiom.soap.SOAPFaultText) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 8 with SOAPFaultText

use of org.apache.axiom.soap.SOAPFaultText in project wso2-synapse by wso2.

the class MessageHelper method cloneSOAPFault.

/**
 * Clones the SOAPFault, fault cloning is not the same as cloning the OMElement because if the
 * Fault is accessed through the SOAPEnvelope.getBody().getFault() method it will lead to a
 * class cast because the cloned element is just an OMElement but not a Fault.
 *
 * @param fault that needs to be cloned
 * @return the cloned fault
 */
public static SOAPFault cloneSOAPFault(SOAPFault fault) {
    SOAPFactory fac;
    int soapVersion;
    final int SOAP_11 = 1;
    final int SOAP_12 = 2;
    if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(fault.getNamespace().getNamespaceURI())) {
        fac = OMAbstractFactory.getSOAP11Factory();
        soapVersion = SOAP_11;
    } else {
        fac = OMAbstractFactory.getSOAP12Factory();
        soapVersion = SOAP_12;
    }
    SOAPFault newFault = fac.createSOAPFault();
    SOAPFaultCode code = fac.createSOAPFaultCode();
    SOAPFaultReason reason = fac.createSOAPFaultReason();
    switch(soapVersion) {
        case SOAP_11:
            code.setText(fault.getCode().getTextAsQName());
            reason.setText(fault.getReason().getText());
            break;
        case SOAP_12:
            SOAPFaultValue value = fac.createSOAPFaultValue(code);
            value.setText(fault.getCode().getTextAsQName());
            for (Object obj : fault.getReason().getAllSoapTexts()) {
                SOAPFaultText text = fac.createSOAPFaultText();
                text.setText(((SOAPFaultText) obj).getText());
                reason.addSOAPText(text);
            }
            break;
    }
    newFault.setCode(code);
    newFault.setReason(reason);
    if (fault.getNode() != null) {
        SOAPFaultNode soapfaultNode = fac.createSOAPFaultNode();
        soapfaultNode.setNodeValue(fault.getNode().getNodeValue());
        newFault.setNode(soapfaultNode);
    }
    if (fault.getRole() != null) {
        SOAPFaultRole soapFaultRole = fac.createSOAPFaultRole();
        soapFaultRole.setRoleValue(fault.getRole().getRoleValue());
        newFault.setRole(soapFaultRole);
    }
    if (fault.getDetail() != null) {
        SOAPFaultDetail soapFaultDetail = fac.createSOAPFaultDetail();
        for (Iterator itr = fault.getDetail().getAllDetailEntries(); itr.hasNext(); ) {
            Object element = itr.next();
            if (element instanceof OMElement) {
                soapFaultDetail.addDetailEntry(((OMElement) element).cloneOMElement());
            }
        }
        newFault.setDetail(soapFaultDetail);
    }
    return newFault;
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) SOAPFaultRole(org.apache.axiom.soap.SOAPFaultRole) SOAPFaultReason(org.apache.axiom.soap.SOAPFaultReason) SOAPFaultValue(org.apache.axiom.soap.SOAPFaultValue) SOAPFaultDetail(org.apache.axiom.soap.SOAPFaultDetail) OMElement(org.apache.axiom.om.OMElement) SOAPFaultText(org.apache.axiom.soap.SOAPFaultText) SOAPFactory(org.apache.axiom.soap.SOAPFactory) SynapseMediationFlowPoint(org.apache.synapse.debug.constructs.SynapseMediationFlowPoint) Iterator(java.util.Iterator) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPFaultNode(org.apache.axiom.soap.SOAPFaultNode)

Aggregations

SOAPFaultText (org.apache.axiom.soap.SOAPFaultText)8 SOAPFaultReason (org.apache.axiom.soap.SOAPFaultReason)5 OMAttribute (org.apache.axiom.om.OMAttribute)3 OMElement (org.apache.axiom.om.OMElement)2 OMNode (org.apache.axiom.om.OMNode)2 SOAPFault (org.apache.axiom.soap.SOAPFault)2 SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)2 SOAPFaultDetail (org.apache.axiom.soap.SOAPFaultDetail)2 SOAPFaultNode (org.apache.axiom.soap.SOAPFaultNode)2 SOAPFaultRole (org.apache.axiom.soap.SOAPFaultRole)2 SOAPFaultValue (org.apache.axiom.soap.SOAPFaultValue)2 StringReader (java.io.StringReader)1 Iterator (java.util.Iterator)1 QName (javax.xml.namespace.QName)1 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)1 SOAPBody (org.apache.axiom.soap.SOAPBody)1 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1 SOAPFactory (org.apache.axiom.soap.SOAPFactory)1 SOAPFaultSubCode (org.apache.axiom.soap.SOAPFaultSubCode)1 SOAPHeader (org.apache.axiom.soap.SOAPHeader)1