List of usage examples for javax.xml.soap SOAPException SOAPException
public SOAPException(Throwable cause)
From source file:com.googlecode.ddom.frontend.saaj.impl.AbstractSOAPPartImpl.java
public final void setParentElement(SOAPElement parent) throws SOAPException { throw new SOAPException("The parent element of a soap part is not defined"); }
From source file:com.streamreduce.util.JiraClient.java
public SOAPMessage invokeSoap(JiraStudioApp app, String soapBody) throws SOAPException { String cacheKey = (app + "-SOAP-" + soapBody.hashCode()); Object objectFromCache = requestCache.getIfPresent(cacheKey); if (objectFromCache != null) { debugLog(LOGGER, " (From cache)"); return (SOAPMessage) objectFromCache; }/* w ww. j av a 2 s. c om*/ // Wrap the SOAP body content in an envelope/body container StringBuilder sb = new StringBuilder(); String soapBaseURL = getBaseUrl(); String soapNamespaceURL; sb.append("<soapenv:Envelope ").append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ") .append("xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" ") .append("xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" "); switch (app) { case CONFLUENCE: soapNamespaceURL = "http://soap.rpc.confluence.atlassian.com"; soapBaseURL += "/wiki/rpc/soap-axis/confluenceservice-v1"; break; case JIRA: soapNamespaceURL = "http://soap.rpc.jira.atlassian.com"; soapBaseURL += "/rpc/soap/jirasoapservice-v2"; break; default: throw new SOAPException("Unknown Jira Studio application: " + app); } sb.append("xmlns:soap=\"" + soapNamespaceURL + "\">\n"); sb.append("<soapenv:Body>\n"); sb.append(soapBody); sb.append("</soapenv:Body></soapenv:Envelope>"); String rawResponse; List<Header> requestHeaders = new ArrayList<>(); requestHeaders.add(new BasicHeader("SOAPAction", "")); try { rawResponse = HTTPUtils.openUrl(soapBaseURL, "POST", sb.toString(), MediaType.TEXT_XML, null, null, requestHeaders, null); } catch (Exception e) { LOGGER.error(String.format("Unable to make SOAP call to %s: %s", soapBaseURL, e.getMessage()), e); throw new SOAPException(e); } Source response = new StreamSource(new StringReader(rawResponse)); MessageFactory msgFactory = MessageFactory.newInstance(); SOAPMessage message = msgFactory.createMessage(); SOAPPart env = message.getSOAPPart(); env.setContent(response); if (message.getSOAPBody().hasFault()) { SOAPFault fault = message.getSOAPBody().getFault(); LOGGER.error("soap fault in jira soap response: " + fault.getFaultString()); } requestCache.put(cacheKey, message); return message; }
From source file:org.apache.axis.attachments.AttachmentPart.java
/** * Gets the <CODE>DataHandler</CODE> object for this <CODE> * AttachmentPart</CODE> object./*from www.j a va 2s . com*/ * @return the <CODE>DataHandler</CODE> object associated with * this <CODE>AttachmentPart</CODE> object * @throws SOAPException if there is * no data in this <CODE>AttachmentPart</CODE> object */ public DataHandler getDataHandler() throws SOAPException { if (datahandler == null) { throw new SOAPException(Messages.getMessage("noContent")); } return datahandler; }
From source file:org.apache.axis.attachments.AttachmentPart.java
/** * Gets the content of this <CODE>AttachmentPart</CODE> object * as a Java object. The type of the returned Java object * depends on (1) the <CODE>DataContentHandler</CODE> object * that is used to interpret the bytes and (2) the <CODE> * Content-Type</CODE> given in the header. * * <P>For the MIME content types "text/plain", "text/html" and * "text/xml", the <CODE>DataContentHandler</CODE> object does * the conversions to and from the Java types corresponding to * the MIME types. For other MIME types,the <CODE> * DataContentHandler</CODE> object can return an <CODE> * InputStream</CODE> object that contains the content data as * raw bytes.</P>//from w ww . j a va 2 s . c o m * * <P>A JAXM-compliant implementation must, as a minimum, * return a <CODE>java.lang.String</CODE> object corresponding * to any content stream with a <CODE>Content-Type</CODE> * value of <CODE>text/plain</CODE> and a <CODE> * javax.xml.transform.StreamSource</CODE> object * corresponding to a content stream with a <CODE> * Content-Type</CODE> value of <CODE>text/xml</CODE>. For * those content types that an installed <CODE> * DataContentHandler</CODE> object does not understand, the * <CODE>DataContentHandler</CODE> object is required to * return a <CODE>java.io.InputStream</CODE> object with the * raw bytes.</P> * @return a Java object with the content of this <CODE> * AttachmentPart</CODE> object * @throws SOAPException if there is no content set * into this <CODE>AttachmentPart</CODE> object or if there * was a data transformation error */ public Object getContent() throws SOAPException { if (contentObject != null) { return contentObject; } if (datahandler == null) { throw new SOAPException(Messages.getMessage("noContent")); } javax.activation.DataSource ds = datahandler.getDataSource(); InputStream is = null; try { is = ds.getInputStream(); ; } catch (java.io.IOException io) { log.error(Messages.getMessage("javaIOException00"), io); throw new SOAPException(io); } if (ds.getContentType().equals("text/plain")) { try { byte[] bytes = new byte[is.available()]; IOUtils.readFully(is, bytes); return new String(bytes); } catch (java.io.IOException io) { log.error(Messages.getMessage("javaIOException00"), io); throw new SOAPException(io); } } else if (ds.getContentType().equals("text/xml")) { return new StreamSource(is); } else if (ds.getContentType().equals("image/gif") || ds.getContentType().equals("image/jpeg")) { try { return ImageIOFactory.getImageIO().loadImage(is); } catch (Exception ex) { log.error(Messages.getMessage("javaIOException00"), ex); throw new SOAPException(ex); } } return is; }
From source file:org.apache.axis.message.MessageElement.java
/** * Sets value of this node to an Object. * A serializer needs to be registered for this object class for proper * operation./* w w w . j ava 2 s.c o m*/ * <p> * Note that this method will log an error and no-op if there are * any children in the MessageElement or if the MessageElement was * constructed from XML. * @param newValue node's value or null. */ public void setObjectValue(Object newValue) throws SOAPException { if (children != null && !children.isEmpty()) { SOAPException exc = new SOAPException(Messages.getMessage("childPresent")); log.error(Messages.getMessage("childPresent"), exc); throw exc; } if (textRep != null) { SOAPException exc = new SOAPException(Messages.getMessage("xmlPresent")); log.error(Messages.getMessage("xmlPresent"), exc); throw exc; } this.objectValue = newValue; }
From source file:org.apache.axis.message.MessageElement.java
/** * The added child must be an instance of MessageElement rather than * an abitrary SOAPElement otherwise a (wrapped) ClassCastException * will be thrown.// w ww . j ava 2 s .c o m * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.SOAPElement) */ public SOAPElement addChildElement(SOAPElement element) throws SOAPException { try { addChild((MessageElement) element); setDirty(); return element; } catch (ClassCastException e) { throw new SOAPException(e); } }
From source file:org.apache.axis.message.MessageElement.java
/** * add a text node to the document.//from w w w . jav a 2s.co m * @return ourselves * @see javax.xml.soap.SOAPElement#addTextNode(String) */ public SOAPElement addTextNode(String s) throws SOAPException { try { Text text = getOwnerDocument().createTextNode(s); ((org.apache.axis.message.Text) text).setParentElement(this); return this; } catch (java.lang.IncompatibleClassChangeError e) { Text text = new org.apache.axis.message.Text(s); this.appendChild(text); return this; } catch (ClassCastException e) { throw new SOAPException(e); } }
From source file:org.apache.axis.message.MessageElement.java
/** * add a new attribute/*from ww w .j av a2s .com*/ * @param attrName name of the attribute * @param value a string value * @return ourselves * @throws SOAPException * @see javax.xml.soap.SOAPElement#addAttribute(javax.xml.soap.Name, String) */ public SOAPElement addAttribute(Name attrName, String value) throws SOAPException { try { addAttribute(attrName.getPrefix(), attrName.getURI(), attrName.getLocalName(), value); } catch (RuntimeException t) { throw new SOAPException(t); } return this; }
From source file:org.apache.axis.message.MessageElement.java
/** * create a {@link Mapping} mapping and add to our namespace list. * @param prefix/*from w ww . ja v a 2 s . c o m*/ * @param uri * @return * @throws SOAPException for any {@link RuntimeException} caught * @todo for some reason this logic catches all rutime exceptions and * rethrows them as SOAPExceptions. This is unusual behavio, and should * be looked at closely. * @see javax.xml.soap.SOAPElement#addNamespaceDeclaration(String, String) */ public SOAPElement addNamespaceDeclaration(String prefix, String uri) throws SOAPException { try { Mapping map = new Mapping(uri, prefix); addMapping(map); } catch (RuntimeException t) { //TODO: why is this here? Nowhere else do we turn runtimes into SOAPExceptions. throw new SOAPException(t); } return this; }
From source file:org.apache.axis.message.NodeImpl.java
/** * Sets the parent of this <code>Node</code> object to the given * <code>SOAPElement</code> object. * //from ww w.j a va 2 s .c om * @param parent the <code>SOAPElement</code> object to be set as * the parent of this <code>Node</code> object * @throws javax.xml.soap.SOAPException if there is a problem in setting the * parent to the given element * @see #getParentElement() getParentElement() */ public void setParentElement(SOAPElement parent) throws SOAPException { if (parent == null) throw new IllegalArgumentException(Messages.getMessage("nullParent00")); try { setParent((NodeImpl) parent); } catch (Throwable t) { throw new SOAPException(t); } }