Package javax.xml.soap

Examples of javax.xml.soap.SOAPException


            MessageContext msgCtx =
                    opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            return getSOAPMessage(msgCtx.getEnvelope());
        } catch (Exception e) {
            throw new SOAPException(e.getMessage(), e);
        }
    }
View Full Code Here


            if (attachment.getContentId() == null ||
                    attachment.getContentId().trim().length() == 0) {
                attachment.setContentId(IDGenerator.generateID());
            }
            if (attachment.getDataHandler() == null) {
                throw new SOAPException("Attachment with NULL DataHandler");
            }
            attachmentMap.put(attachment.getContentId(), attachment);
        }

        //Get keys of attachments to a hashmap
View Full Code Here

    public SOAPMessage get(Object to) throws SOAPException {
        URL url = null;
        try {
            url = (to instanceof URL) ? (URL)to : new URL(to.toString());
        } catch (MalformedURLException e) {
            throw new SOAPException(e);
        }

        int responseCode;
        boolean isFailure = false;
        HttpURLConnection httpCon = null;
        try {
            httpCon = (HttpURLConnection)url.openConnection();
            httpCon.setDoOutput(true);
            httpCon.setDoInput(true);
            httpCon.setUseCaches(false);
            httpCon.setRequestMethod("GET");
            HttpURLConnection.setFollowRedirects(true);

            httpCon.connect();
            responseCode = httpCon.getResponseCode();
            // 500 is allowed for SOAP faults
            if (responseCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                isFailure = true;
            } else if ((responseCode / 100) != 2) {
                throw new SOAPException("Error response: (" + responseCode
                        + httpCon.getResponseMessage());
            }
        } catch (IOException e) {
            throw new SOAPException(e);
        }

        //Construct the soapmessage from http response
        SOAPMessage soapMessage = null;
        if (responseCode == HttpURLConnection.HTTP_OK) {
            try {
                //read http headers & load mimeheaders
                MimeHeaders mimeHeaders = new MimeHeaders();
                String key, value;
                // skip status line
                int i = 1;
                while (true) {
                    key = httpCon.getHeaderFieldKey(i);
                    value = httpCon.getHeaderField(i);
                    if (key == null && value == null) {
                        break;
                    }

                    if (key != null) {
                        StringTokenizer values = new StringTokenizer(value, ",");
                        while (values.hasMoreTokens()) {
                            mimeHeaders.addHeader(key, values.nextToken().trim());
                        }
                    }
                    i++;
                }
                InputStream httpInputStream;
                if (isFailure) {
                    httpInputStream = httpCon.getErrorStream();
                } else {
                    httpInputStream = httpCon.getInputStream();
                }

                soapMessage = new SOAPMessageImpl(httpInputStream, mimeHeaders);
                httpInputStream.close();
                httpCon.disconnect();

            } catch (SOAPException e) {
                throw e;
            } catch (Exception e) {
                throw new SOAPException(e.getMessage());
            }
        }
        return soapMessage;
    }
View Full Code Here

                                                       factory,
                                                       soapEnvelopeNamespaceURI);
                }

            } catch (Exception e) {
                throw new SOAPException(e);
            }
        } else {
            modifiedInputStream = inputStream;
            try {
                isReader = new InputStreamReader(modifiedInputStream);
                XMLStreamReader streamReader = null;
               
                if(knownEncoding != null){
                  streamReader = StAXUtils.createXMLStreamReader(modifiedInputStream, knownEncoding);
                }else{
                  streamReader = StAXUtils.createXMLStreamReader(modifiedInputStream);                 
                }

                if (HTTPConstants.MEDIA_TYPE_TEXT_XML.equals(contentType)) {
                    builder = new StAXSOAPModelBuilder(streamReader,
                                                       new SOAP11Factory(),
                                                       SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

                } else if (HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML.equals(contentType)) {
                    builder = new StAXSOAPModelBuilder(streamReader,
                                                       new SOAP12Factory(),
                                                       SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);

                } else if (HTTPConstants.MEDIA_TYPE_MULTIPART_RELATED.equals(contentType)) {
                    builder = new StAXSOAPModelBuilder(streamReader,
                                                       new SOAP11Factory(),
                                                       null);
                } else {
                    builder = new StAXSOAPModelBuilder(streamReader,
                                                       new SOAP11Factory(),
                                                       null);
                }
            } catch (XMLStreamException e) {
                throw new SOAPException(e);
            }
        }
        try {
            org.apache.axiom.soap.SOAPEnvelope soapEnvelope = builder.getSOAPEnvelope();
            envelope = new SOAPEnvelopeImpl(
                    (org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)soapEnvelope);
            envelope.element.build();
            this.document = envelope.getOwnerDocument();
            envelope.setSOAPPartParent(this);
            javax.xml.transform.Source xmlSource =
                    new javax.xml.transform.stream.StreamSource( isReader);
            this.source = xmlSource;
        } catch (Exception e) {
            throw new SOAPException(e);
        }
    }
View Full Code Here

            envelope.element.build();
            this.document = envelope.getOwnerDocument();
            envelope.setSOAPPartParent(this);
        } catch (TransformerFactoryConfigurationError e) {
            log.error(e);
            throw new SOAPException(e);
        } catch (Exception e) {
            log.error(e);
            throw new SOAPException(e);
        }
    }
View Full Code Here

        return null;       
    }       


    public void setParentElement(SOAPElement parent) throws SOAPException {
      throw new SOAPException("Cannot set the parent element of SOAPPart");
    }
View Full Code Here

    */
    public SOAPElement addChildElement(String localName, String prefix) throws SOAPException {
        String namespaceURI = getNamespaceURI(prefix);

        if (namespaceURI == null) {
            throw new SOAPException("Namespace not declared for the give prefix: " + prefix);
        }
        return addChildElement(localName, prefix, namespaceURI);
    }
View Full Code Here

     */
    public SOAPHeaderElement addHeaderElement(Name name) throws SOAPException {
       
        if (name.getURI() == null
                || name.getURI().trim().length() == 0) {
            throw new SOAPException("SOAP1.1 and SOAP1.2 requires all HeaderElements to have " +
                    "a namespace.");
        }
        String prefix = name.getPrefix() == null ? "" : name.getPrefix();
        OMNamespace ns = new NamespaceImpl(name.getURI(), prefix);

View Full Code Here

    public SOAPElement addTextNode(String text) throws SOAPException {
        if (this.element.getOMFactory() instanceof SOAP11Factory) {
            return super.addTextNode(text);
        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
            throw new SOAPException("Cannot add text node to SOAPHeader");
        } else {
            return null;
        }
    }
View Full Code Here

      */
    public SOAPElement addChildElement(String localName, String prefix) throws SOAPException {
        String namespaceURI = getNamespaceURI(prefix);

        if (namespaceURI == null) {
            throw new SOAPException("Namespace not declared for the give prefix: " + prefix);
        }

        SOAPElementImpl childEle =
                new SOAPElementImpl((ElementImpl)getOwnerDocument().
                        createElementNS(namespaceURI, prefix + ":" + localName));
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.