Search in sources :

Example 11 with SOAPFaultCode

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

the class TestGetValueWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPFaultCode code = envelope.getBody().getFault().getCode();
    assertNull(code.getValue());
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode)

Example 12 with SOAPFaultCode

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

the class TestGetSubCodeWithParser method runTest.

@Override
protected void runTest(SOAPEnvelope envelope) throws Throwable {
    SOAPFaultCode faultCode = envelope.getBody().getFault().getCode();
    assertNotNull("SOAP 1.2 Fault Code Test with parser :- getSubCode method returns null", faultCode.getSubCode());
    assertEquals("SOAP 1.2 Fault Code Test with parser : - subcode local name mismatch", SOAP12Constants.SOAP_FAULT_SUB_CODE_LOCAL_NAME, faultCode.getSubCode().getLocalName());
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode)

Example 13 with SOAPFaultCode

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

the class TestSetValueFromQName method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFaultCode code = soapFactory.createSOAPFaultCode();
    code.setValue(new QName("urn:test", "MyFaultCode", "p"));
    SOAPFaultValue value = code.getValue();
    assertNotNull(value);
    assertEquals("p:MyFaultCode", value.getText());
    Iterator<OMNamespace> it = value.getAllDeclaredNamespaces();
    assertTrue(it.hasNext());
    OMNamespace ns = it.next();
    assertEquals("p", ns.getPrefix());
    assertEquals("urn:test", ns.getNamespaceURI());
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) QName(javax.xml.namespace.QName) SOAPFaultValue(org.apache.axiom.soap.SOAPFaultValue)

Example 14 with SOAPFaultCode

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

the class TestSetValueFromQNameWithExistingValue method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFaultCode code = soapFactory.getDefaultFaultEnvelope().getBody().getFault().getCode();
    SOAPFaultValue value = code.getValue();
    assertNotNull(value);
    code.setValue(new QName("urn:test", "MyFaultCode", "p"));
    assertEquals("p:MyFaultCode", value.getText());
    Iterator<OMNamespace> it = value.getAllDeclaredNamespaces();
    assertTrue(it.hasNext());
    OMNamespace ns = it.next();
    assertEquals("p", ns.getPrefix());
    assertEquals("urn:test", ns.getNamespaceURI());
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) QName(javax.xml.namespace.QName) SOAPFaultValue(org.apache.axiom.soap.SOAPFaultValue)

Example 15 with SOAPFaultCode

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

the class SOAPElementTypeAdapterFactory method createAdapters.

@Override
public void createAdapters(SOAPElementType type, Adapters adapters) {
    if (type == SOAPElementType.ENVELOPE) {
        adapters.add(new SOAPElementTypeAdapter(SOAPEnvelope.class, null, null) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPEnvelope();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                throw new UnsupportedOperationException();
            }
        });
    } else if (type == SOAPElementType.HEADER) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPEnvelope) parent).getHeader();
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPHeader.class, getter, null) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPHeader();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPHeader((SOAPEnvelope) parent);
            }
        });
    } else if (type == SOAPElementType.BODY) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPEnvelope) parent).getBody();
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPBody.class, getter, null) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPBody();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPBody((SOAPEnvelope) parent);
            }
        });
    } else if (type == SOAPElementType.FAULT) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPBody) parent).getFault();
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPFault.class, getter, null) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFault();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPFault((SOAPBody) parent);
            }
        });
    } else if (type == SOAPFaultChild.CODE) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPFault) parent).getCode();
            }
        };
        Setter setter = new Setter() {

            @Override
            public void invoke(OMElement parent, OMElement child) {
                ((SOAPFault) parent).setCode((SOAPFaultCode) child);
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPFaultCode.class, getter, setter) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFaultCode();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPFaultCode((SOAPFault) parent);
            }
        });
    } else if (type == SOAPElementType.VALUE) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPFaultClassifier) parent).getValue();
            }
        };
        Setter setter = new Setter() {

            @Override
            public void invoke(OMElement parent, OMElement child) {
                ((SOAPFaultClassifier) parent).setValue((SOAPFaultValue) child);
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPFaultValue.class, getter, setter) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFaultValue();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                if (parentType == SOAPFaultChild.CODE) {
                    return factory.createSOAPFaultValue((SOAPFaultCode) parent);
                } else {
                    return factory.createSOAPFaultValue((SOAPFaultSubCode) parent);
                }
            }
        });
    } else if (type == SOAPElementType.SUB_CODE) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPFaultClassifier) parent).getSubCode();
            }
        };
        Setter setter = new Setter() {

            @Override
            public void invoke(OMElement parent, OMElement child) {
                ((SOAPFaultClassifier) parent).setSubCode((SOAPFaultSubCode) child);
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPFaultSubCode.class, getter, setter) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFaultSubCode();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                if (parentType == SOAPFaultChild.CODE) {
                    return factory.createSOAPFaultSubCode((SOAPFaultCode) parent);
                } else {
                    return factory.createSOAPFaultSubCode((SOAPFaultSubCode) parent);
                }
            }
        });
    } else if (type == SOAPFaultChild.REASON) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPFault) parent).getReason();
            }
        };
        Setter setter = new Setter() {

            @Override
            public void invoke(OMElement parent, OMElement child) {
                ((SOAPFault) parent).setReason((SOAPFaultReason) child);
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPFaultReason.class, getter, setter) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFaultReason();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPFaultReason((SOAPFault) parent);
            }
        });
    } else if (type == SOAPElementType.TEXT) {
        adapters.add(new SOAPElementTypeAdapter(SOAPFaultText.class, null, null) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFaultText();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPFaultText((SOAPFaultReason) parent);
            }
        });
    } else if (type == SOAPFaultChild.NODE) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPFault) parent).getNode();
            }
        };
        Setter setter = new Setter() {

            @Override
            public void invoke(OMElement parent, OMElement child) {
                ((SOAPFault) parent).setNode((SOAPFaultNode) child);
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPFaultNode.class, getter, setter) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFaultNode();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPFaultNode((SOAPFault) parent);
            }
        });
    } else if (type == SOAPFaultChild.ROLE) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPFault) parent).getRole();
            }
        };
        Setter setter = new Setter() {

            @Override
            public void invoke(OMElement parent, OMElement child) {
                ((SOAPFault) parent).setRole((SOAPFaultRole) child);
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPFaultRole.class, getter, setter) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFaultRole();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPFaultRole((SOAPFault) parent);
            }
        });
    } else if (type == SOAPFaultChild.DETAIL) {
        Getter getter = new Getter() {

            @Override
            public OMElement invoke(OMElement parent) {
                return ((SOAPFault) parent).getDetail();
            }
        };
        Setter setter = new Setter() {

            @Override
            public void invoke(OMElement parent, OMElement child) {
                ((SOAPFault) parent).setDetail((SOAPFaultDetail) child);
            }
        };
        adapters.add(new SOAPElementTypeAdapter(SOAPFaultDetail.class, getter, setter) {

            @Override
            public OMElement create(SOAPFactory factory) {
                return factory.createSOAPFaultDetail();
            }

            @Override
            public OMElement create(SOAPFactory factory, SOAPElementType parentType, OMElement parent) {
                return factory.createSOAPFaultDetail((SOAPFault) parent);
            }
        });
    }
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) SOAPFaultRole(org.apache.axiom.soap.SOAPFaultRole) Getter(org.apache.axiom.ts.soap.SOAPElementTypeAdapter.Getter) SOAPFaultReason(org.apache.axiom.soap.SOAPFaultReason) SOAPFaultValue(org.apache.axiom.soap.SOAPFaultValue) SOAPFaultDetail(org.apache.axiom.soap.SOAPFaultDetail) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPFaultText(org.apache.axiom.soap.SOAPFaultText) SOAPFactory(org.apache.axiom.soap.SOAPFactory) SOAPFaultSubCode(org.apache.axiom.soap.SOAPFaultSubCode) SOAPBody(org.apache.axiom.soap.SOAPBody) Setter(org.apache.axiom.ts.soap.SOAPElementTypeAdapter.Setter) SOAPFaultClassifier(org.apache.axiom.soap.SOAPFaultClassifier) SOAPFault(org.apache.axiom.soap.SOAPFault) SOAPFaultNode(org.apache.axiom.soap.SOAPFaultNode)

Aggregations

SOAPFaultCode (org.apache.axiom.soap.SOAPFaultCode)20 SOAPFault (org.apache.axiom.soap.SOAPFault)11 QName (javax.xml.namespace.QName)9 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)9 SOAPFaultReason (org.apache.axiom.soap.SOAPFaultReason)7 OMElement (org.apache.axiom.om.OMElement)6 SOAPFaultDetail (org.apache.axiom.soap.SOAPFaultDetail)6 SOAPFaultValue (org.apache.axiom.soap.SOAPFaultValue)6 SOAPFactory (org.apache.axiom.soap.SOAPFactory)4 SOAPFaultRole (org.apache.axiom.soap.SOAPFaultRole)4 OMNamespace (org.apache.axiom.om.OMNamespace)3 OMNode (org.apache.axiom.om.OMNode)3 SOAPBody (org.apache.axiom.soap.SOAPBody)3 SOAPFaultNode (org.apache.axiom.soap.SOAPFaultNode)3 SOAPFaultSubCode (org.apache.axiom.soap.SOAPFaultSubCode)3 SOAPFaultText (org.apache.axiom.soap.SOAPFaultText)3 StringReader (java.io.StringReader)2 OMAttribute (org.apache.axiom.om.OMAttribute)2 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)2 SOAPHeader (org.apache.axiom.soap.SOAPHeader)2