com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl Java Examples
The following examples show how to use
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Fault1_2Impl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public Iterator getFaultReasonLocales() throws SOAPException { // Fault Reason has similar semantics as faultstring if (this.faultStringElement == null) findReasonElement(); Iterator eachTextElement = this.faultStringElement.getChildElements(textName); List localeSet = new ArrayList(); while (eachTextElement.hasNext()) { SOAPElement textElement = (SOAPElement) eachTextElement.next(); Locale thisLocale = getLocale(textElement); if (thisLocale == null) { log.severe("SAAJ0431.ver1_2.xml.lang.missing"); throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element"); } localeSet.add(thisLocale); } if (localeSet.isEmpty()) { log.severe("SAAJ0434.ver1_2.text.element.not.present"); throw new SOAPExceptionImpl("env:Text elements with mandatory xml:lang attributes must be present inside env:Reason"); } return localeSet.iterator(); }
Example #2
Source File: AttachmentPartImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void copyMimeHeaders(MimeBodyPart mbp, AttachmentPartImpl ap) throws SOAPException { try { List hdr = mbp.getAllHeaders(); int sz = hdr.size(); for( int i=0; i<sz; i++ ) { Header h = (Header)hdr.get(i); if(h.getName().equalsIgnoreCase("Content-Type")) continue; // skip ap.addMimeHeader(h.getName(), h.getValue()); } } catch (Exception ex) { log.severe("SAAJ0506.soap.cannot.copy.mime.hdrs.into.attachment"); throw new SOAPExceptionImpl( "Unable to copy MIME headers into attachment", ex); } }
Example #3
Source File: Fault1_2Impl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public Iterator<Locale> getFaultReasonLocales() throws SOAPException { // Fault Reason has similar semantics as faultstring if (this.faultStringElement == null) findReasonElement(); Iterator eachTextElement = this.faultStringElement.getChildElements(textName); List<Locale> localeSet = new ArrayList<>(); while (eachTextElement.hasNext()) { SOAPElement textElement = (SOAPElement) eachTextElement.next(); Locale thisLocale = getLocale(textElement); if (thisLocale == null) { log.severe("SAAJ0431.ver1_2.xml.lang.missing"); throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element"); } localeSet.add(thisLocale); } if (localeSet.isEmpty()) { log.severe("SAAJ0434.ver1_2.text.element.not.present"); throw new SOAPExceptionImpl("env:Text elements with mandatory xml:lang attributes must be present inside env:Reason"); } return localeSet.iterator(); }
Example #4
Source File: EnvelopeImpl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public SOAPBody addBody(String prefix) throws SOAPException { lookForBody(); if (prefix == null || prefix.equals("")) { prefix = getPrefix(); } if (body == null) { NameImpl bodyName = getBodyName(prefix); body = (BodyImpl) createElement(bodyName); insertBefore(body, null); body.ensureNamespaceIsDeclared(bodyName.getPrefix(), bodyName.getURI()); } else { log.severe("SAAJ0122.impl.body.already.exists"); throw new SOAPExceptionImpl("Can't add a body when one is already present."); } return body; }
Example #5
Source File: Fault1_2Impl.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private SOAPElement getFaultReasonTextElement(Locale locale) throws SOAPException { // Fault Reason has similar semantics as faultstring Iterator eachTextElement = this.faultStringElement.getChildElements(textName); while (eachTextElement.hasNext()) { SOAPElement textElement = (SOAPElement) eachTextElement.next(); Locale thisLocale = getLocale(textElement); if (thisLocale == null) { log.severe("SAAJ0431.ver1_2.xml.lang.missing"); throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element"); } if (thisLocale.equals(locale)) { return textElement; } } return null; }
Example #6
Source File: AttachmentPartImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
MimeBodyPart getMimePart() throws SOAPException { try { if (this.mimePart != null) { return new MimeBodyPart(mimePart); } if (rawContent != null) { copyMimeHeaders(headers, rawContent); return rawContent; } MimeBodyPart envelope = new MimeBodyPart(); envelope.setDataHandler(dataHandler); copyMimeHeaders(headers, envelope); return envelope; } catch (Exception ex) { log.severe("SAAJ0504.soap.cannot.externalize.attachment"); throw new SOAPExceptionImpl("Unable to externalize attachment", ex); } }
Example #7
Source File: HeaderImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public SOAPHeaderElement addHeaderElement(QName name) throws SOAPException { SOAPElement newHeaderElement = ElementFactory.createNamedElement( ((SOAPDocument) getOwnerDocument()).getDocument(), name.getLocalPart(), name.getPrefix(), name.getNamespaceURI()); if (newHeaderElement == null || !(newHeaderElement instanceof SOAPHeaderElement)) { newHeaderElement = createHeaderElement(name); } // header elements must be namespace qualified // check that URI is not empty, ensuring that the element is NS qualified. String uri = newHeaderElement.getElementQName().getNamespaceURI(); if ((uri == null) || ("").equals(uri)) { log.severe("SAAJ0131.impl.header.elems.ns.qualified"); throw new SOAPExceptionImpl("HeaderElements must be namespace qualified"); } addNode(newHeaderElement); return (SOAPHeaderElement) newHeaderElement; }
Example #8
Source File: AttachmentPartImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
MimeBodyPart getMimePart() throws SOAPException { try { if (this.mimePart != null) { return new MimeBodyPart(mimePart); } if (rawContent != null) { copyMimeHeaders(headers, rawContent); return rawContent; } MimeBodyPart envelope = new MimeBodyPart(); envelope.setDataHandler(dataHandler); copyMimeHeaders(headers, envelope); return envelope; } catch (Exception ex) { log.severe("SAAJ0504.soap.cannot.externalize.attachment"); throw new SOAPExceptionImpl("Unable to externalize attachment", ex); } }
Example #9
Source File: AttachmentPartImpl.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void copyMimeHeaders(MimeBodyPart mbp, AttachmentPartImpl ap) throws SOAPException { try { List hdr = mbp.getAllHeaders(); int sz = hdr.size(); for( int i=0; i<sz; i++ ) { Header h = (Header)hdr.get(i); if(h.getName().equalsIgnoreCase("Content-Type")) continue; // skip ap.addMimeHeader(h.getName(), h.getValue()); } } catch (Exception ex) { log.severe("SAAJ0506.soap.cannot.copy.mime.hdrs.into.attachment"); throw new SOAPExceptionImpl( "Unable to copy MIME headers into attachment", ex); } }
Example #10
Source File: SOAPPartImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
protected void lookForEnvelope() throws SOAPException { Element envelopeChildElement = document.doGetDocumentElement(); if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) { envelope = (EnvelopeImpl) envelopeChildElement; } else if (!(envelopeChildElement instanceof ElementImpl)) { log.severe("SAAJ0512.soap.incorrect.factory.used"); throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction"); } else { ElementImpl soapElement = (ElementImpl) envelopeChildElement; if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) { String prefix = soapElement.getPrefix(); String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix); if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) { log.severe("SAAJ0513.soap.unknown.ns"); throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized"); } } else { log.severe("SAAJ0514.soap.root.elem.not.named.envelope"); throw new SOAPExceptionImpl( "Unable to create envelope from given source because the root element is not named \"Envelope\""); } } }
Example #11
Source File: SOAPPartImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
protected void lookForEnvelope() throws SOAPException { Element envelopeChildElement = document.doGetDocumentElement(); if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) { envelope = (EnvelopeImpl) envelopeChildElement; } else if (!(envelopeChildElement instanceof ElementImpl)) { log.severe("SAAJ0512.soap.incorrect.factory.used"); throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction"); } else { ElementImpl soapElement = (ElementImpl) envelopeChildElement; if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) { String prefix = soapElement.getPrefix(); String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix); if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) { log.severe("SAAJ0513.soap.unknown.ns"); throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized"); } } else { log.severe("SAAJ0514.soap.root.elem.not.named.envelope"); throw new SOAPExceptionImpl( "Unable to create envelope from given source because the root element is not named \"Envelope\""); } } }
Example #12
Source File: MessageFactoryImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public SOAPMessage createMessage(MimeHeaders headers, XMLStreamReader reader) throws SOAPException, IOException { String contentTypeString = MessageImpl.getContentType(headers); if (listener != null) { throw new SOAPException("Listener OutputStream is not supported with XMLStreamReader"); } try { ContentType contentType = new ContentType(contentTypeString); int stat = MessageImpl.identifyContentType(contentType); if (MessageImpl.isSoap1_1Content(stat)) { return new Message1_1Impl(headers,contentType,stat,reader); } else if (MessageImpl.isSoap1_2Content(stat)) { return new Message1_2Impl(headers,contentType,stat,reader); } else { log.severe("SAAJ0530.soap.unknown.Content-Type"); throw new SOAPExceptionImpl("Unrecognized Content-Type"); } } catch (ParseException e) { log.severe("SAAJ0531.soap.cannot.parse.Content-Type"); throw new SOAPExceptionImpl( "Unable to parse content type: " + e.getMessage()); } }
Example #13
Source File: EnvelopeImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public SOAPBody addBody(String prefix) throws SOAPException { lookForBody(); if (prefix == null || prefix.equals("")) { prefix = getPrefix(); } if (body == null) { NameImpl bodyName = getBodyName(prefix); body = (BodyImpl) createElement(bodyName); insertBefore(body.getDomElement(), null); body.ensureNamespaceIsDeclared(bodyName.getPrefix(), bodyName.getURI()); } else { log.severe("SAAJ0122.impl.body.already.exists"); throw new SOAPExceptionImpl("Can't add a body when one is already present."); } return body; }
Example #14
Source File: Fault1_2Impl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private SOAPElement getFaultReasonTextElement(Locale locale) throws SOAPException { // Fault Reason has similar semantics as faultstring Iterator eachTextElement = this.faultStringElement.getChildElements(textName); while (eachTextElement.hasNext()) { SOAPElement textElement = (SOAPElement) eachTextElement.next(); Locale thisLocale = getLocale(textElement); if (thisLocale == null) { log.severe("SAAJ0431.ver1_2.xml.lang.missing"); throw new SOAPExceptionImpl("\"xml:lang\" attribute is not present on the Text element"); } if (thisLocale.equals(locale)) { return textElement; } } return null; }
Example #15
Source File: EnvelopeImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public Name createName(String localName, String prefix, String uri) throws SOAPException { // validating parameters before passing them on // to make sure that the namespace specification rules are followed // reserved xmlns prefix cannot be used. if ("xmlns".equals(prefix)) { log.severe("SAAJ0123.impl.no.reserved.xmlns"); throw new SOAPExceptionImpl("Cannot declare reserved xmlns prefix"); } // Qualified name cannot be xmlns. if ((prefix == null) && ("xmlns".equals(localName))) { log.severe("SAAJ0124.impl.qualified.name.cannot.be.xmlns"); throw new SOAPExceptionImpl("Qualified name cannot be xmlns"); } return NameImpl.create(localName, prefix, uri); }
Example #16
Source File: Fault1_2Impl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override protected void checkIfStandardFaultCode(String faultCode, String uri) throws SOAPException { QName qname = new QName(uri, faultCode); if (SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT.equals(qname) || SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT.equals(qname) || SOAPConstants.SOAP_RECEIVER_FAULT.equals(qname) || SOAPConstants.SOAP_SENDER_FAULT.equals(qname) || SOAPConstants.SOAP_VERSIONMISMATCH_FAULT.equals(qname)) return; log.log( Level.SEVERE, "SAAJ0435.ver1_2.code.not.standard", qname); throw new SOAPExceptionImpl(qname + " is not a standard Code value"); }
Example #17
Source File: AttachmentPartImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void copyMimeHeaders(MimeBodyPart mbp, AttachmentPartImpl ap) throws SOAPException { try { List hdr = mbp.getAllHeaders(); int sz = hdr.size(); for( int i=0; i<sz; i++ ) { Header h = (Header)hdr.get(i); if(h.getName().equalsIgnoreCase("Content-Type")) continue; // skip ap.addMimeHeader(h.getName(), h.getValue()); } } catch (Exception ex) { log.severe("SAAJ0506.soap.cannot.copy.mime.hdrs.into.attachment"); throw new SOAPExceptionImpl( "Unable to copy MIME headers into attachment", ex); } }
Example #18
Source File: FaultImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void setFaultCode(String faultCode, String prefix, String uri) throws SOAPException { if (prefix == null || "".equals(prefix)) { if (uri != null && !"".equals(uri)) { prefix = getNamespacePrefix(uri); if (prefix == null || "".equals(prefix)) { prefix = "ns0"; } } } if (this.faultCodeElement == null) findFaultCodeElement(); if (this.faultCodeElement == null) this.faultCodeElement = addFaultCodeElement(); else this.faultCodeElement.removeContents(); if (uri == null || "".equals(uri)) { uri = this.faultCodeElement.getNamespaceURI(prefix); } if (uri == null || "".equals(uri)) { if (prefix != null && !"".equals(prefix)) { //cannot allow an empty URI for a non-Empty prefix log.log(Level.SEVERE, "SAAJ0140.impl.no.ns.URI", new Object[]{prefix + ":" + faultCode}); throw new SOAPExceptionImpl("Empty/Null NamespaceURI specified for faultCode \"" + prefix + ":" + faultCode + "\""); } else { uri = ""; } } checkIfStandardFaultCode(faultCode, uri); ((FaultElementImpl) this.faultCodeElement).ensureNamespaceIsDeclared(prefix, uri); if (prefix == null || "".equals(prefix)) { finallySetFaultCode(faultCode); } else { finallySetFaultCode(prefix + ":" + faultCode); } }
Example #19
Source File: Fault1_2Impl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public SOAPElement addTextNode(String text) throws SOAPException { log.log( Level.SEVERE, "SAAJ0416.ver1_2.adding.text.not.legal", getElementQName()); throw new SOAPExceptionImpl("Adding text to SOAP 1.2 Fault is not legal"); }
Example #20
Source File: Envelope1_2Impl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public SOAPElement addChildElement(Name name) throws SOAPException { // check if body already exists if (getBody() != null) { log.severe("SAAJ0405.ver1_2.body.must.last.in.envelope"); throw new SOAPExceptionImpl( "Body must be the last element in" + " SOAP Envelope"); } return super.addChildElement(name); }
Example #21
Source File: SOAPMessageFactory1_1Impl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public SOAPMessage createMessage(MimeHeaders headers, InputStream in) throws IOException, SOAPExceptionImpl { if (headers == null) { headers = new MimeHeaders(); } if (getContentType(headers) == null) { headers.setHeader("Content-Type", SOAPConstants.SOAP_1_1_CONTENT_TYPE); } MessageImpl msg = new Message1_1Impl(headers, in); msg.setLazyAttachments(lazyAttachments); return msg; }
Example #22
Source File: Body1_2Impl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public SOAPElement addChildElement(QName name) throws SOAPException { if (hasFault()) { log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body"); throw new SOAPExceptionImpl( "No other element except Fault allowed in SOAPBody"); } return super.addChildElement(name); }
Example #23
Source File: Header1_2Impl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected SOAPHeaderElement createHeaderElement(Name name) throws SOAPException { String uri = name.getURI(); if (uri == null || uri.equals("")) { log.severe("SAAJ0413.ver1_2.header.elems.must.be.ns.qualified"); throw new SOAPExceptionImpl("SOAP 1.2 header elements must be namespace qualified"); } return new HeaderElement1_2Impl( ((SOAPDocument) getOwnerDocument()).getDocument(), name); }
Example #24
Source File: AttachmentPartImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public DataHandler getDataHandler() throws SOAPException { if (mimePart != null) { //return an inputstream return new DataHandler(new DataSource() { @Override public InputStream getInputStream() throws IOException { return mimePart.read(); } @Override public OutputStream getOutputStream() throws IOException { throw new UnsupportedOperationException("getOutputStream cannot be supported : You have enabled LazyAttachments Option"); } @Override public String getContentType() { return mimePart.getContentType(); } @Override public String getName() { return "MIMEPart Wrapper DataSource"; } }); } if (dataHandler == null) { if (rawContent != null) { return new DataHandler(new MimePartDataSource(rawContent)); } log.severe("SAAJ0502.soap.no.handler.for.attachment"); throw new SOAPExceptionImpl("No data handler associated with this attachment"); } return dataHandler; }
Example #25
Source File: Body1_2Impl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
protected SOAPElement addElement(Name name) throws SOAPException { if (hasFault()) { log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body"); throw new SOAPExceptionImpl( "No other element except Fault allowed in SOAPBody"); } return super.addElement(name); }
Example #26
Source File: Body1_2Impl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public SOAPBodyElement addBodyElement(QName name) throws SOAPException { if (hasFault()) { log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body"); throw new SOAPExceptionImpl( "No other element except Fault allowed in SOAPBody"); } return super.addBodyElement(name); }
Example #27
Source File: Body1_2Impl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public SOAPElement addChildElement(QName name) throws SOAPException { if (hasFault()) { log.severe("SAAJ0402.ver1_2.only.fault.allowed.in.body"); throw new SOAPExceptionImpl( "No other element except Fault allowed in SOAPBody"); } return super.addChildElement(name); }
Example #28
Source File: Fault1_2Impl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected void checkIfStandardFaultCode(String faultCode, String uri) throws SOAPException { QName qname = new QName(uri, faultCode); if (SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT.equals(qname) || SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT.equals(qname) || SOAPConstants.SOAP_RECEIVER_FAULT.equals(qname) || SOAPConstants.SOAP_SENDER_FAULT.equals(qname) || SOAPConstants.SOAP_VERSIONMISMATCH_FAULT.equals(qname)) return; log.log( Level.SEVERE, "SAAJ0435.ver1_2.code.not.standard", qname); throw new SOAPExceptionImpl(qname + " is not a standard Code value"); }
Example #29
Source File: Fault1_1Impl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public SOAPElement addChildElement(SOAPElement element) throws SOAPException { String localName = element.getLocalName(); if ("Detail".equalsIgnoreCase(localName)) { if (hasDetail()) { log.severe("SAAJ0305.ver1_2.detail.exists.error"); throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists"); } } return super.addChildElement(element); }
Example #30
Source File: HttpSOAPConnection.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void close() throws SOAPException { if (closed) { log.severe("SAAJ0002.p2p.close.already.closed.conn"); throw new SOAPExceptionImpl("Connection already closed"); } messageFactory = null; closed = true; }