List of usage examples for org.springframework.oxm MarshallingFailureException MarshallingFailureException
public MarshallingFailureException(String msg, Throwable cause)
From source file:org.javelin.sws.ext.bind.SoapEncodingMarshaller.java
@Override public void marshal(Object graph, Result result) throws IOException, XmlMappingException { try {//from w w w . ja va 2 s. c o m ContentHandler contentHandler = ((SAXResult) result).getHandler(); contentHandler.startElement("", "hello", "hello", new AttributesImpl()); contentHandler.characters(((String) ((Object[]) graph)[0]).toCharArray(), 0, ((String) ((Object[]) graph)[0]).toCharArray().length); contentHandler.endElement("", "hello", "hello"); } catch (SAXException e) { throw new MarshallingFailureException(e.getMessage(), e); } }
From source file:org.springbyexample.httpclient.HttpClientOxmTemplate.java
/** * Execute post method./*from w ww . ja v a2s .c o m*/ * * @param uri URI to use when processing this HTTP request instead * of using the default URI. * @param requestPayload Request data to post after marshalling. * The <code>Marshaller</code> should be able to * process this instance. * @param hParams Parameters for the HTTP post. * @param callback Callback with HTTP method's response. */ public void executePostMethod(String uri, T requestPayload, Map<String, String> hParams, ResponseCallback<?> callback) { PostMethod post = new PostMethod(uri); if (requestPayload != null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { marshaller.marshal(requestPayload, new StreamResult(out)); } catch (IOException e) { throw new MarshallingFailureException(e.getMessage(), e); } post.setRequestEntity(new ByteArrayRequestEntity(out.toByteArray())); } processHttpMethodParams(post, hParams); processHttpMethod(post, callback); }
From source file:org.springframework.oxm.jaxb.Jaxb2Marshaller.java
/** * Convert the given {@code JAXBException} to an appropriate exception from the * {@code org.springframework.oxm} hierarchy. * @param ex {@code JAXBException} that occurred * @return the corresponding {@code XmlMappingException} *//* w ww . j a v a2s.com*/ protected XmlMappingException convertJaxbException(JAXBException ex) { if (ex instanceof ValidationException) { return new ValidationFailureException("JAXB validation exception", ex); } else if (ex instanceof MarshalException) { return new MarshallingFailureException("JAXB marshalling exception", ex); } else if (ex instanceof UnmarshalException) { return new UnmarshallingFailureException("JAXB unmarshalling exception", ex); } else { // fallback return new UncategorizedMappingException("Unknown JAXB exception", ex); } }
From source file:org.springframework.oxm.xmlbeans.XmlBeansMarshaller.java
/** * Convert the given XMLBeans exception to an appropriate exception from the * <code>org.springframework.oxm</code> hierarchy. * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or * unmarshalling, since XMLBeans itself does not make this distinction in its exception hierarchy. * @param ex XMLBeans Exception that occured * @param marshalling indicates whether the exception occurs during marshalling (<code>true</code>), * or unmarshalling (<code>false</code>) * @return the corresponding <code>XmlMappingException</code> *//*w w w . j a v a 2 s. c om*/ protected XmlMappingException convertXmlBeansException(Exception ex, boolean marshalling) { if (ex instanceof XMLStreamValidationException) { return new ValidationFailureException("XmlBeans validation exception", ex); } else if (ex instanceof XmlException || ex instanceof SAXException) { if (marshalling) { return new MarshallingFailureException("XMLBeans marshalling exception", ex); } else { return new UnmarshallingFailureException("XMLBeans unmarshalling exception", ex); } } else { // fallback return new UncategorizedMappingException("Unknown XMLBeans exception", ex); } }