Search in sources :

Example 16 with SOAPProcessingException

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

the class OMXMLBuilderFactory method createSOAPModelBuilder.

/**
     * Create an MTOM aware model builder from the provided {@link MultipartBody} object using a
     * particular Axiom implementation. The method will determine the SOAP version based on the
     * content type information from the {@link MultipartBody} object. It will configure the
     * underlying parser as specified by {@link StAXParserConfiguration#SOAP}.
     * 
     * @param metaFactory
     *            the meta factory for the Axiom implementation to use
     * @param message
     *            the MIME message
     * @return the builder
     * @throws OMException
     *             if an error occurs while processing the content type information from the
     *             {@link MultipartBody} object
     */
public static SOAPModelBuilder createSOAPModelBuilder(OMMetaFactory metaFactory, MultipartBody message) {
    String type = message.getRootPart().getContentType().getParameter("type");
    SOAPFactory soapFactory;
    if ("text/xml".equalsIgnoreCase(type)) {
        soapFactory = metaFactory.getSOAP11Factory();
    } else if ("application/soap+xml".equalsIgnoreCase(type)) {
        soapFactory = metaFactory.getSOAP12Factory();
    } else {
        throw new OMException("Unable to determine SOAP version");
    }
    SOAPModelBuilder builder = ((OMMetaFactorySPI) metaFactory).createSOAPModelBuilder(message);
    if (builder.getSOAPMessage().getOMFactory() != soapFactory) {
        throw new SOAPProcessingException("Invalid SOAP namespace URI. " + "Expected " + soapFactory.getSoapVersionURI(), SOAP12Constants.FAULT_CODE_SENDER);
    }
    return builder;
}
Also used : SOAPProcessingException(org.apache.axiom.soap.SOAPProcessingException) SOAPModelBuilder(org.apache.axiom.soap.SOAPModelBuilder) SOAPFactory(org.apache.axiom.soap.SOAPFactory)

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