Package javax.xml.ws.soap

Examples of javax.xml.ws.soap.SOAPFaultException


            SOAPBody body = soapMessage.getSOAPBody();
            SOAPFault soapFault = body.addFault();

            if (exception instanceof SOAPFaultException) {
                SOAPFaultException sf = (SOAPFaultException)exception;
                soapFault.setFaultString(sf.getFault().getFaultString());
                soapFault.setFaultCode(sf.getFault().getFaultCode());
                soapFault.setFaultActor(sf.getFault().getFaultActor());
                if (sf.getFault().hasDetail()) {
                    Node nd = soapMessage.getSOAPPart().importNode(sf.getFault().getDetail(),
                                                                   true);
                    nd = nd.getFirstChild();
                    soapFault.addDetail();
                    while (nd != null) {
                        soapFault.getDetail().appendChild(nd);
                        nd = nd.getNextSibling();
                    }
                }
            } else if (exception instanceof Fault) {
                SoapFault sf = SoapFault.createFault((Fault)exception, ((SoapMessage)msg).getVersion());
                soapFault.setFaultString(sf.getReason());
                soapFault.setFaultCode(sf.getFaultCode());
                if (sf.hasDetails()) {
                    soapFault.addDetail();
                    Node nd = soapMessage.getSOAPPart().importNode(sf.getDetail(), true);
                    nd = nd.getFirstChild();
                    while (nd != null) {
                        soapFault.getDetail().appendChild(nd);
                        nd = nd.getNextSibling();
                    }
View Full Code Here


        AddNumbersHandlerService service = new AddNumbersHandlerService();
        AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();

        BindingProvider p = (BindingProvider)proxy;
        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
        SOAPFaultException expectedException = null;
        Throwable t = null;
        try {
            proxy.addNumbersHandler(-1000, Integer.MIN_VALUE);
           
        } catch (Throwable e) {
            // An exception is expected
            t = e;
           
        }
       
        // Make sure the proper exception is thrown
        if (t == null) {
            fail("Expected AddNumbersHandlerFault_Exception to be thrown");
        }
       
        if (t instanceof SOAPFaultException) {
            expectedException = (SOAPFaultException) t;
        } else {
            fail("Expected SOAPFaultException to be thrown, " +
                        "but the exception is: " + t);
        }
      
        // also confirm that @PreDestroy method is called.  Since it only makes sense to call it on the managed
        // (server) side and just before the handler instance goes out of scope, we are creating a file in the
        // @PreDestroy method, and will check for its existance here.  If the file does not exist, it means
        // @PreDestroy method was never called.  The file is set to .deleteOnExit(), so no need to delete it.
        File file = new File("AddNumbersProtocolHandler.preDestroy.txt");
        assertTrue("File AddNumbersProtocolHandler.preDestroy.txt does not exist, meaning the @PreDestroy method was not called.", file.exists());

        String log = readLogFile();
        String expected_calls =
            "AddNumbersLogicalHandler2 POST_CONSTRUCT\n"
            + "AddNumbersProtocolHandler2 GET_HEADERS\n"
            + "AddNumbersProtocolHandler GET_HEADERS\n"
            + "AddNumbersProtocolHandler HANDLE_MESSAGE_INBOUND\n"
            + "AddNumbersProtocolHandler2 HANDLE_MESSAGE_INBOUND\n"
            + "AddNumbersLogicalHandler2 HANDLE_MESSAGE_INBOUND\n"
            + "AddNumbersLogicalHandler HANDLE_MESSAGE_INBOUND\n"
            + "AddNumbersLogicalHandler HANDLE_FAULT_OUTBOUND\n"
            + "AddNumbersLogicalHandler2 HANDLE_FAULT_OUTBOUND\n"
            + "AddNumbersProtocolHandler2 HANDLE_FAULT_OUTBOUND\n"
            + "AddNumbersProtocolHandler HANDLE_FAULT_OUTBOUND\n"
            + "AddNumbersLogicalHandler CLOSE\n"
            + "AddNumbersLogicalHandler2 CLOSE\n"
            + "AddNumbersProtocolHandler2 CLOSE\n"
            + "AddNumbersProtocolHandler CLOSE\n"
            + "AddNumbersProtocolHandler PRE_DESTROY\n";
       
        assertTrue("Expected : " + expected_calls + " but received " + log, expected_calls.equals(log));
       
        // The outbound service handler adds the stack trace to the
        // message.  Make sure the stack trace contains the AddNumbersHandlerPortTypeImpl
       
        TestLogger.logger.debug("Expected Exception is " +
                                expectedException.getMessage());
       
        SOAPFault fault = expectedException.getFault();
        assertTrue("A stack trace was not present in the returned exception's message:" +
                   fault.getFaultString(),
                   fault.getFaultString().indexOf("AddNumbersHandlerPortTypeImpl") > 0);
                  
View Full Code Here

        AddNumbersHandlerService service = new AddNumbersHandlerService();
        AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();

        BindingProvider p = (BindingProvider)proxy;
        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
        SOAPFaultException expectedException = null;
        Throwable t = null;
        try {
            // Trigger protocol 2 to throw an exception
            AddNumbersProtocolHandler2.throwException = true;
            proxy.addNumbersHandler(-1000, Integer.MIN_VALUE);
View Full Code Here

            } else if (getBinding() instanceof SOAPBinding) {
                SOAPFault soapFault = createSoapFault((SOAPBinding)getBinding(), ex);
                if (soapFault == null) {
                    throw new WebServiceException(ex);
                }
                SOAPFaultException  exception = new SOAPFaultException(soapFault);
                if (ex instanceof Fault && ex.getCause() != null) {
                    exception.initCause(ex.getCause());
                } else {
                    exception.initCause(ex);
                }
                throw exception;               
            } else {
                throw new WebServiceException(ex);
            }
View Full Code Here

                                                                 new Exception(error.toString()));
                } catch (SOAPException e) {
                    //ignore
                }
                if (soapFault != null) {
                    throw new SOAPFaultException(soapFault);
                }
            } else if (getBinding() instanceof HTTPBinding) {
                HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
                exception.initCause(new Exception(error.toString()));
                throw exception;
View Full Code Here

            }
            if (soapFault == null) {
                return new WebServiceException(ex);
            }
           
            SOAPFaultException  exception = new SOAPFaultException(soapFault);
            exception.initCause(ex);
            return exception;               
        }
        return new WebServiceException(ex);
    }
View Full Code Here

                DetailEntry de = detail.addDetailEntry(qName);
                qName = new QName(WSTRUST_13_NAMESPACE, "ErrorCode", "ns");
                SOAPElement errorElement = de.addChildElement(qName);
                StackTraceElement[] ste = e.getStackTrace();
                errorElement.setTextContent(ste[0].toString());
                throw new SOAPFaultException(fault);
            } catch (SOAPException e1) {
                throw new Fault(e1);
            }

        }
View Full Code Here

                body.removeContents();

                SOAPFault soapFault = body.addFault();

                if (exception instanceof SOAPFaultException) {
                    SOAPFaultException sf = (SOAPFaultException)exception;
                    soapFault.setFaultString(sf.getFault().getFaultString());
                    soapFault.setFaultCode(sf.getFault().getFaultCodeAsQName());
                    soapFault.setFaultActor(sf.getFault().getFaultActor());
                    if (sf.getFault().hasDetail()) {
                        Node nd = originalMsg.getSOAPPart().importNode(
                                                                       sf.getFault().getDetail()
                                                                           .getFirstChild(), true);
                        soapFault.addDetail().appendChild(nd);
                    }
                } else if (exception instanceof Fault) {
                    SoapFault sf = SoapFault.createFault((Fault)exception, ((SoapMessage)message)
                        .getVersion());
                    soapFault.setFaultString(sf.getReason());
                    soapFault.setFaultCode(sf.getFaultCode());
                    if (sf.hasDetails()) {
                        soapFault.addDetail();
                        Node nd = originalMsg.getSOAPPart().importNode(sf.getDetail(), true);
                        nd = nd.getFirstChild();
                        while (nd != null) {
                            soapFault.getDetail().appendChild(nd);
                            nd = nd.getNextSibling();
                        }
View Full Code Here

                                                                 new Exception(error.toString()));
                } catch (SOAPException e) {
                    //ignore
                }
                if (soapFault != null) {
                    throw new SOAPFaultException(soapFault);
                }
            } else if (getBinding() instanceof HTTPBinding) {
                HTTPException exception = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
                exception.initCause(new Exception(error.toString()));
                throw exception;
View Full Code Here

            }
            if (soapFault == null) {
                return new WebServiceException(ex);
            }
           
            SOAPFaultException  exception = new SOAPFaultException(soapFault);
            exception.initCause(ex);
            return exception;               
        }
        return new WebServiceException(ex);
    }
View Full Code Here

TOP

Related Classes of javax.xml.ws.soap.SOAPFaultException

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.