List of usage examples for javax.xml.soap SOAPFactory createFault
public abstract SOAPFault createFault() throws SOAPException;
From source file:be.fedict.eid.idp.protocol.saml2.artifact.ArtifactServiceServerHandler.java
private SOAPFaultException createSOAPFaultException(String faultString) { SOAPFault soapFault;//from w w w . ja v a2 s .c o m try { SOAPFactory soapFactory = SOAPFactory.newInstance(); soapFault = soapFactory.createFault(); soapFault.setFaultString(faultString); } catch (SOAPException e) { throw new RuntimeException("SOAP error"); } return new SOAPFaultException(soapFault); }
From source file:edu.duke.cabig.c3pr.webservice.studyimportexport.impl.StudyImportExportImpl.java
/** * Creates the soap fault.//from w w w. ja va2s . c om * * @param msg the msg * @return the sOAP fault */ private SOAPFault createSOAPFault(String msg) { try { SOAPFactory factory = SOAPFactory.newInstance(); SOAPFault fault = factory.createFault(); fault.setFaultString(msg); fault.setFaultCode(new QName(SOAP_NS, SOAP_FAULT_CODE)); Detail detail = fault.addDetail(); final Element detailEntry = detail.getOwnerDocument().createElementNS(SERVICE_NS, STUDY_IMPORT_FAULT); detail.appendChild(detailEntry); final Element detailMsg = detail.getOwnerDocument().createElementNS(SERVICE_NS, FAULT_MESSAGE); detailMsg.setTextContent(msg); detailEntry.appendChild(detailMsg); return fault; } catch (SOAPException e) { log.error(ExceptionUtils.getFullStackTrace(e)); throw new WebServiceException(e); } }
From source file:de.unibi.techfak.bibiserv.BiBiTools.java
/** * Returns a SOAPFaultException with specified * * @param faultcode/* w w w . j a v a 2s. c o m*/ * @param faultstring * @param hobitstatuscode * @param hobitstatusdescription * @return */ public static SOAPFaultException createSOAPFaultException(String faultcode, String faultstring, String hobitstatuscode, String hobitstatusdescription) { SOAPFault fault = null; try { SOAPFactory sfi = SOAPFactory.newInstance(); fault = sfi.createFault(); fault.setFaultCode(new QName("http://schemas.xmlsoap.org/soap/envelope/", faultcode, "soap")); fault.setFaultString(faultstring); if (hobitstatuscode != null && hobitstatusdescription != null) { Detail detail = fault.addDetail(); DetailEntry detailentry = detail.addDetailEntry(new QName( "http://hobit.sourceforge.net/xsds/hobitStatuscode.xsd", "hobitStatuscode", "status")); SOAPElement statuscode = detailentry.addChildElement( new QName("http://hobit.sourceforge.net/xsds/hobitStatuscode.xsd", "statuscode", "status")); statuscode.addTextNode(hobitstatuscode); SOAPElement description = detailentry.addChildElement(new QName( "http://hobit.sourceforge.net/xsds/hobitStatuscode.xsd", "description", "status")); description.addTextNode(hobitstatusdescription); } } catch (SOAPException e) { log.fatal("SOAPException occured : " + e.getMessage()); } return new SOAPFaultException(fault); }
From source file:org.apache.axis2.saaj.SOAPFactoryTest.java
@Validated @Test/*from ww w .ja v a2s . c o m*/ public void testCreateElement3() { try { SOAPFactory factory = SOAPFactory.newInstance(); if (factory == null) { fail("createFaultTest1() could not create SOAPFactory object"); } SOAPFault sf = factory.createFault(); if (sf == null) { fail("createFault() returned null"); } else if (!(sf instanceof SOAPFault)) { fail("createFault() did not create a SOAPFault object"); } } catch (Exception e) { fail(); } }