Search in sources :

Example 1 with SOAPProcessingException

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

the class TestGetBooleanAttributeInvalid method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeader header = soapFactory.getDefaultEnvelope().getOrCreateHeader();
    SOAPHeaderBlock headerBlock = header.addHeaderBlock(new QName("urn:test", "test", "p"));
    headerBlock.addAttribute(attribute.getName(spec), value, header.getNamespace());
    try {
        attribute.getAdapter(BooleanAttributeAccessor.class).getValue(headerBlock);
        fail("Expected SOAPProcessingException");
    } catch (SOAPProcessingException ex) {
    // Expected
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) BooleanAttributeAccessor(org.apache.axiom.ts.soap.BooleanAttributeAccessor) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPHeader(org.apache.axiom.soap.SOAPHeader)

Example 2 with SOAPProcessingException

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

the class TestWrongParent1 method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPFaultCode parent = soapFactory.createSOAPFaultCode();
    SOAPFault fault = soapFactory.createSOAPFault();
    try {
        parent.addChild(fault);
        fail("Expected SOAPProcessingException");
    } catch (SOAPProcessingException ex) {
    // Expected
    }
}
Also used : SOAPFaultCode(org.apache.axiom.soap.SOAPFaultCode) SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) SOAPFault(org.apache.axiom.soap.SOAPFault)

Example 3 with SOAPProcessingException

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

the class TestCreateSOAPModelBuilderMTOMContentTypeMismatch method runTest.

@Override
protected void runTest() throws Throwable {
    final SOAPSample sample = SOAPSampleSet.NO_HEADER.getMessage(spec);
    // Generate an MTOM message with the wrong content type
    MimeMessage message = new MimeMessage((Session) null);
    MimeMultipart mp = new MimeMultipart("related");
    MimeBodyPart bp = new MimeBodyPart();
    String contentID = "<" + UIDGenerator.generateContentId() + ">";
    bp.setDataHandler(new DataHandler(new DataSource() {

        @Override
        public String getContentType() {
            return "application/xop+xml; charset=\"" + sample.getEncoding() + "\"; type=\"" + spec.getAltSpec().getContentType() + "\"";
        }

        @Override
        public InputStream getInputStream() throws IOException {
            return sample.getInputStream();
        }

        @Override
        public String getName() {
            return null;
        }

        @Override
        public OutputStream getOutputStream() {
            throw new UnsupportedOperationException();
        }
    }));
    bp.addHeader("Content-Transfer-Encoding", "binary");
    bp.addHeader("Content-ID", contentID);
    mp.addBodyPart(bp);
    message.setContent(mp);
    message.saveChanges();
    ContentType contentType = new ContentType(message.getContentType()).toBuilder().setParameter("type", "application/xop+xml").setParameter("start", contentID).setParameter("start-info", spec.getAltSpec().getContentType()).build();
    MemoryBlob blob = Blobs.createMemoryBlob();
    OutputStream out = blob.getOutputStream();
    mp.writeTo(out);
    out.close();
    // Now attempt to create an Axiom builder
    try {
        OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, MultipartBody.builder().setInputStream(blob.getInputStream()).setContentType(contentType).build());
        fail("Expected SOAPProcessingException");
    } catch (SOAPProcessingException ex) {
    // Expected
    }
}
Also used : ContentType(org.apache.axiom.mime.ContentType) MimeMessage(javax.mail.internet.MimeMessage) MimeMultipart(javax.mail.internet.MimeMultipart) MemoryBlob(org.apache.axiom.blob.MemoryBlob) OutputStream(java.io.OutputStream) SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) DataHandler(javax.activation.DataHandler) SOAPSample(org.apache.axiom.ts.soap.SOAPSample) MimeBodyPart(javax.mail.internet.MimeBodyPart) DataSource(javax.activation.DataSource)

Example 4 with SOAPProcessingException

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

the class TestAddElementAfterBody method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPEnvelope env = soapFactory.createSOAPEnvelope();
    if (header) {
        soapFactory.createSOAPHeader(env);
    }
    soapFactory.createSOAPBody(env);
    OMElement elem = env.getOMFactory().createOMElement(new QName("foo"));
    if (spec.isAllowsElementsAfterBody()) {
        env.addChild(elem);
    } else {
        try {
            env.addChild(elem);
            fail("Expected SOAPProcessingException");
        } catch (SOAPProcessingException ex) {
        // expected
        }
    }
}
Also used : QName(javax.xml.namespace.QName) SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Example 5 with SOAPProcessingException

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

the class BadInputTest method runTest.

@Override
protected void runTest() throws Throwable {
    try {
        SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, BadInputTest.class.getClassLoader().getResourceAsStream("badsoap/" + file), null).getSOAPEnvelope();
        OMTestUtils.walkThrough(soapEnvelope);
        fail("this must failed gracefully with SOAPProcessingException");
    } catch (SOAPProcessingException e) {
        return;
    }
}
Also used : SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope)

Aggregations

SOAPProcessingException (org.apache.axiom.soap.SOAPProcessingException)16 OMElement (org.apache.axiom.om.OMElement)8 SOAPFault (org.apache.axiom.soap.SOAPFault)4 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)4 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)3 QName (javax.xml.namespace.QName)2 AxiomElement (org.apache.axiom.om.impl.intf.AxiomElement)2 SOAPHeader (org.apache.axiom.soap.SOAPHeader)2 SOAPModelBuilder (org.apache.axiom.soap.SOAPModelBuilder)2 OutputStream (java.io.OutputStream)1 StringReader (java.io.StringReader)1 Vector (java.util.Vector)1 DataHandler (javax.activation.DataHandler)1 DataSource (javax.activation.DataSource)1 MimeBodyPart (javax.mail.internet.MimeBodyPart)1 MimeMessage (javax.mail.internet.MimeMessage)1 MimeMultipart (javax.mail.internet.MimeMultipart)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 MemoryBlob (org.apache.axiom.blob.MemoryBlob)1 ContentType (org.apache.axiom.mime.ContentType)1