@Bean public SaajSoapMessageFactory messageFactory() { return new SaajSoapMessageFactory(); }
/** * Creates SAAJ based message factory. * @param soapVersion * @return */ public static WebServiceMessageFactory createMessageFactory(SoapVersion soapVersion) { SaajSoapMessageFactory saajSoapMessageFactory = new SaajSoapMessageFactory(); saajSoapMessageFactory.setSoapVersion(soapVersion); saajSoapMessageFactory.afterPropertiesSet(); return saajSoapMessageFactory; }
SaajSoapMessageFactory factory = new SaajSoapMessageFactory( javax.xml.soap.MessageFactory.newInstance()); SaajSoapMessage message = factory.createWebServiceMessage();
@Bean(name = SpringWsUriBuilder.MESSAGE_FACTORY_SOAP12) public SoapMessageFactory messageFactorySOAP12() { SaajSoapMessageFactory factory = new SaajSoapMessageFactory(); factory.setSoapVersion(SoapVersion.SOAP_12); return factory; }
@Override public SaajSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException { MimeHeaders mimeHeaders = parseMimeHeaders(inputStream); try { inputStream = checkForUtf8ByteOrderMark(inputStream); SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); saajMessage.getSOAPPart().getEnvelope(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); try { SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString); SAXParseException parseException = getSAXParseException(ex); if (parseException != null) { throw new InvalidXmlException("Could not parse XML", parseException);
public SaajSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException { MimeHeaders mimeHeaders = parseMimeHeaders(inputStream); try { inputStream = checkForUtf8ByteOrderMark(inputStream); SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); } catch (SOAPException ex) { // SAAJ 1.3 RI has a issue with handling multipart XOP content types which contain "startinfo" rather than // "start-info", so let's try and do something about it String contentType = StringUtils .arrayToCommaDelimitedString(mimeHeaders.getHeader(TransportConstants.HEADER_CONTENT_TYPE)); if (contentType.indexOf("startinfo") != -1) { contentType = contentType.replace("startinfo", "start-info"); mimeHeaders.setHeader(TransportConstants.HEADER_CONTENT_TYPE, contentType); try { SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString); } catch (SOAPException e) { // fall-through } } throw new SoapMessageCreationException("Could not create message from InputStream: " + ex.getMessage(), ex); } }
@Override public SaajSoapMessage createWebServiceMessage() { try { SOAPMessage saajMessage = messageFactory.createMessage(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); } catch (SOAPException ex) { throw new SoapMessageCreationException("Could not create empty message: " + ex.getMessage(), ex); } }
private SAXParseException getSAXParseException(Throwable ex) { if (ex instanceof SAXParseException) { return (SAXParseException) ex; } else if (ex.getCause() != null) { return getSAXParseException(ex.getCause()); } else { return null; } }
/** * Checks for the UTF-8 Byte Order Mark, and removes it if present. The SAAJ RI cannot cope with these BOMs. * * @see <a href="http://jira.springframework.org/browse/SWS-393">SWS-393</a> * @see <a href="http://unicode.org/faq/utf_bom.html#22">UTF-8 BOMs</a> */ private InputStream checkForUtf8ByteOrderMark(InputStream inputStream) throws IOException { PushbackInputStream pushbackInputStream = new PushbackInputStream(new BufferedInputStream(inputStream), 3); byte[] bytes = new byte[3]; int bytesRead = 0; while (bytesRead < bytes.length) { int n = pushbackInputStream.read(bytes, bytesRead, bytes.length - bytesRead); if (n > 0) { bytesRead += n; } else { break; } } if (bytesRead > 0) { // check for the UTF-8 BOM, and remove it if there. See SWS-393 if (!isByteOrderMark(bytes)) { pushbackInputStream.unread(bytes, 0, bytesRead); } } return pushbackInputStream; }
SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory(MessageFactory.newInstance()); messageFactory.afterPropertiesSet(); WebServiceTemplate webServiceTemplate = new WebServiceTemplate(messageFactory); Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPath("models"); marshaller.afterPropertiesSet(); webServiceTemplate.setMarshaller(marshaller); webServiceTemplate.afterPropertiesSet();
@Override public SaajSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException { MimeHeaders mimeHeaders = parseMimeHeaders(inputStream); try { inputStream = checkForUtf8ByteOrderMark(inputStream); SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); saajMessage.getSOAPPart().getEnvelope(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); try { SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString); SAXParseException parseException = getSAXParseException(ex); if (parseException != null) { throw new InvalidXmlException("Could not parse XML", parseException);
@Bean(name = SpringWsUriBuilder.MESSAGE_FACTORY_SOAP11) public SoapMessageFactory messageFactorySOAP11() { SaajSoapMessageFactory factory = new SaajSoapMessageFactory(); factory.setSoapVersion(SoapVersion.SOAP_11); return factory; }
public SaajSoapMessage createWebServiceMessage() { try { SOAPMessage saajMessage = messageFactory.createMessage(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); } catch (SOAPException ex) { throw new SoapMessageCreationException("Could not create empty message: " + ex.getMessage(), ex); } }
private SAXParseException getSAXParseException(Throwable ex) { if (ex instanceof SAXParseException) { return (SAXParseException) ex; } else if (ex.getCause() != null) { return getSAXParseException(ex.getCause()); } else { return null; } }
/** * Checks for the UTF-8 Byte Order Mark, and removes it if present. The SAAJ RI cannot cope with these BOMs. * * @see <a href="http://jira.springframework.org/browse/SWS-393">SWS-393</a> * @see <a href="http://unicode.org/faq/utf_bom.html#22">UTF-8 BOMs</a> */ private InputStream checkForUtf8ByteOrderMark(InputStream inputStream) throws IOException { PushbackInputStream pushbackInputStream = new PushbackInputStream(new BufferedInputStream(inputStream), 3); byte[] bytes = new byte[3]; int bytesRead = 0; while (bytesRead < bytes.length) { int n = pushbackInputStream.read(bytes, bytesRead, bytes.length - bytesRead); if (n > 0) { bytesRead += n; } else { break; } } if (bytesRead > 0) { // check for the UTF-8 BOM, and remove it if there. See SWS-393 if (!isByteOrderMark(bytes)) { pushbackInputStream.unread(bytes, 0, bytesRead); } } return pushbackInputStream; }
try { SaajSoapMessageFactory messageFactory = new SaajSoapMessageFactory( MessageFactory.newInstance()); messageFactory.afterPropertiesSet(); WebServiceTemplate webServiceTemplate = new WebServiceTemplate( messageFactory); Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPath("PACKAGE"); marshaller.afterPropertiesSet(); webServiceTemplate.setMarshaller(marshaller); webServiceTemplate.afterPropertiesSet(); Response response = (Response) webServiceTemplate .marshalSendAndReceive( "address", searchFlights); Response msg = (Response) response; } catch (Exception s) { s.printStackTrace(); }
@Override public SaajSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException { MimeHeaders mimeHeaders = parseMimeHeaders(inputStream); try { inputStream = checkForUtf8ByteOrderMark(inputStream); SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); saajMessage.getSOAPPart().getEnvelope(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); try { SOAPMessage saajMessage = messageFactory.createMessage(mimeHeaders, inputStream); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString); SAXParseException parseException = getSAXParseException(ex); if (parseException != null) { throw new InvalidXmlException("Could not parse XML", parseException);
@Bean protected SoapMessageFactory getMessageFactory() { return new SaajSoapMessageFactory(); }
@Override public SaajSoapMessage createWebServiceMessage() { try { SOAPMessage saajMessage = messageFactory.createMessage(); postProcess(saajMessage); return new SaajSoapMessage(saajMessage, langAttributeOnSoap11FaultString, messageFactory); } catch (SOAPException ex) { throw new SoapMessageCreationException("Could not create empty message: " + ex.getMessage(), ex); } }
private SAXParseException getSAXParseException(Throwable ex) { if (ex instanceof SAXParseException) { return (SAXParseException) ex; } else if (ex.getCause() != null) { return getSAXParseException(ex.getCause()); } else { return null; } }