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;
}
Aggregations