/** * Creates a new default SOAPFault object * * @return a SOAPFault object * @throws SOAPException - if there is a SOAP error */ public SOAPFault createFault() throws SOAPException { org.apache.axiom.soap.SOAPFactory soapFactory; if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) { soapFactory = metaFactory.getSOAP12Factory(); return new SOAPFaultImpl(soapFactory.createSOAPFault()); } else { soapFactory = metaFactory.getSOAP11Factory(); return new SOAPFaultImpl(soapFactory.createSOAPFault()); } }
/** * Crete SOAP Fault from fault information returned from ODE. * * @param bpelMessageContext DTO containing information on current messageflow. * @param odeMessageContext ODE MyRoleMessageExchange containing information on current process * invocation. * @return SOAPFault instance * @throws AxisFault in case of a error while creating SOAP Fault. */ public static SOAPFault createSoapFault(final BPELMessageContext bpelMessageContext, final MessageExchange odeMessageContext) throws AxisFault { SOAPFactory soapFactory = bpelMessageContext.getSoapFactoryForCurrentMessageFlow(); OMElement detail = buildSoapDetail(bpelMessageContext, odeMessageContext); SOAPFault fault = soapFactory.createSOAPFault(); SOAPFaultCode code = soapFactory.createSOAPFaultCode(fault); code.setText(new QName(Namespaces.SOAP_ENV_NS, "Server")); SOAPFaultReason reason = soapFactory.createSOAPFaultReason(fault); reason.setText(odeMessageContext.getFault()); SOAPFaultDetail soapDetail = soapFactory.createSOAPFaultDetail(fault); if (detail != null) { soapDetail.addDetailEntry(detail); } return fault; }
private SOAPFault addStandardFault(String localName, String faultStringOrReason, Locale locale) { Assert.notNull(faultStringOrReason, "No faultStringOrReason given"); try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode code = getAxiomFactory().createSOAPFaultCode(fault); SOAPFaultValue value = getAxiomFactory().createSOAPFaultValue(code); value.setText(fault.getNamespace().getPrefix() + ":" + localName); SOAPFaultReason reason = getAxiomFactory().createSOAPFaultReason(fault); SOAPFaultText text = getAxiomFactory().createSOAPFaultText(reason); if (locale != null) { text.setLang(AxiomUtils.toLanguage(locale)); } text.setText(faultStringOrReason); return fault; } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
@Override public Soap11Fault addFault(QName code, String faultString, Locale faultStringLocale) { Assert.notNull(code, "No faultCode given"); Assert.hasLength(faultString, "faultString cannot be empty"); if (!StringUtils.hasLength(code.getNamespaceURI())) { throw new IllegalArgumentException( "A fault code with namespace and local part must be specific for a custom fault code"); } if (!langAttributeOnSoap11FaultString) { faultStringLocale = null; } try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault); setValueText(code, fault, faultCode); SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault); if (faultStringLocale != null) { addLangAttribute(faultStringLocale, faultReason); } faultReason.setText(faultString); return new AxiomSoap11Fault(fault, getAxiomFactory()); } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
private SOAPFault addStandardFault(String localName, String faultStringOrReason, Locale locale) { Assert.notNull(faultStringOrReason, "No faultStringOrReason given"); try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode code = getAxiomFactory().createSOAPFaultCode(fault); SOAPFaultValue value = getAxiomFactory().createSOAPFaultValue(code); value.setText(fault.getNamespace().getPrefix() + ":" + localName); SOAPFaultReason reason = getAxiomFactory().createSOAPFaultReason(fault); SOAPFaultText text = getAxiomFactory().createSOAPFaultText(reason); if (locale != null) { text.setLang(AxiomUtils.toLanguage(locale)); } text.setText(faultStringOrReason); return fault; } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
private SOAPFault addStandardFault(String localName, String faultString, Locale locale) { Assert.notNull(faultString, "No faultString given"); try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault); faultCode.setText(new QName(fault.getNamespace().getNamespaceURI(), localName, fault.getNamespace().getPrefix())); SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault); if (locale != null) { addLangAttribute(locale, faultReason); } faultReason.setText(faultString); return fault; } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
/** * Creates a new default SOAPFault object * * @return a SOAPFault object * @throws SOAPException - if there is a SOAP error */ public SOAPFault createFault() throws SOAPException { org.apache.axiom.soap.SOAPFactory soapFactory; if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) { soapFactory = metaFactory.getSOAP12Factory(); return new SOAPFaultImpl(soapFactory.createSOAPFault()); } else { soapFactory = metaFactory.getSOAP11Factory(); return new SOAPFaultImpl(soapFactory.createSOAPFault()); } }
private SOAPFault addStandardFault(String localName, String faultStringOrReason, Locale locale) { Assert.notNull(faultStringOrReason, "No faultStringOrReason given"); try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode code = getAxiomFactory().createSOAPFaultCode(fault); SOAPFaultValue value = getAxiomFactory().createSOAPFaultValue(code); value.setText(fault.getNamespace().getPrefix() + ":" + localName); SOAPFaultReason reason = getAxiomFactory().createSOAPFaultReason(fault); SOAPFaultText text = getAxiomFactory().createSOAPFaultText(reason); if (locale != null) { text.setLang(AxiomUtils.toLanguage(locale)); } text.setText(faultStringOrReason); return fault; } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
private SOAPFault addStandardFault(String localName, String faultString, Locale locale) { Assert.notNull(faultString, "No faultString given"); try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault); faultCode.setText(new QName(fault.getNamespace().getNamespaceURI(), localName, fault.getNamespace().getPrefix())); SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault); if (locale != null) { addLangAttribute(locale, faultReason); } faultReason.setText(faultString); return fault; } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
private Iterator getChildren(Iterator childIter) { Collection childElements = new ArrayList(); while (childIter.hasNext()) { org.w3c.dom.Node domNode = (org.w3c.dom.Node)childIter.next(); org.w3c.dom.Node saajNode = toSAAJNode(domNode); if (saajNode instanceof javax.xml.soap.Text) { childElements.add(saajNode); } else if (!(saajNode instanceof SOAPBodyElement)) { // silently replace node, as per saaj 1.2 spec if (domNode instanceof Element) { if (omTarget.hasFault()) { SOAPFactory omFactory = (SOAPFactory)this.omTarget.getOMFactory(); org.apache.axiom.soap.SOAPFault fault = omFactory.createSOAPFault(omTarget); childElements.add(new SOAPFaultImpl(fault)); } else { childElements.add(new SOAPBodyElementImpl<OMElement>((OMElement)domNode)); } } } else { childElements.add(saajNode); } } return childElements.iterator(); } }
private SOAPFault addStandardFault(String localName, String faultStringOrReason, Locale locale) { Assert.notNull(faultStringOrReason, "No faultStringOrReason given"); try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode code = getAxiomFactory().createSOAPFaultCode(fault); SOAPFaultValue value = getAxiomFactory().createSOAPFaultValue(code); value.setText(fault.getNamespace().getPrefix() + ":" + localName); SOAPFaultReason reason = getAxiomFactory().createSOAPFaultReason(fault); SOAPFaultText text = getAxiomFactory().createSOAPFaultText(reason); if (locale != null) { text.setLang(AxiomUtils.toLanguage(locale)); } text.setText(faultStringOrReason); return fault; } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
private SOAPFault addStandardFault(String localName, String faultString, Locale locale) { Assert.notNull(faultString, "No faultString given"); try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault); faultCode.setText(new QName(fault.getNamespace().getNamespaceURI(), localName, fault.getNamespace().getPrefix())); SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault); if (locale != null) { addLangAttribute(locale, faultReason); } faultReason.setText(faultString); return fault; } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
private Iterator getChildren(Iterator<? extends OMNode> childIter) { Collection childElements = new ArrayList(); while (childIter.hasNext()) { org.w3c.dom.Node domNode = (org.w3c.dom.Node)childIter.next(); org.w3c.dom.Node saajNode = toSAAJNode(domNode); if (saajNode instanceof javax.xml.soap.Text) { childElements.add(saajNode); } else if (!(saajNode instanceof SOAPBodyElement)) { // silently replace node, as per saaj 1.2 spec if (domNode instanceof Element) { if (omTarget.hasFault()) { SOAPFactory omFactory = (SOAPFactory)this.omTarget.getOMFactory(); org.apache.axiom.soap.SOAPFault fault = omFactory.createSOAPFault(omTarget); childElements.add(new SOAPFaultImpl(fault)); } else { childElements.add(new SOAPBodyElementImpl<OMElement>((OMElement)domNode)); } } } else { childElements.add(saajNode); } } return childElements.iterator(); } }
private SOAPFault addStandardFault(String localName, String faultString, Locale locale) { Assert.notNull(faultString, "No faultString given"); try { AxiomUtils.removeContents(getAxiomBody()); SOAPFault fault = getAxiomFactory().createSOAPFault(getAxiomBody()); SOAPFaultCode faultCode = getAxiomFactory().createSOAPFaultCode(fault); faultCode.setText(QNameUtils.createQName(fault.getNamespace().getNamespaceURI(), localName, fault.getNamespace().getPrefix())); SOAPFaultReason faultReason = getAxiomFactory().createSOAPFaultReason(fault); if (locale != null) { addLangAttribute(locale, faultReason); } faultReason.setText(faultString); return fault; } catch (SOAPProcessingException ex) { throw new AxiomSoapFaultException(ex); } }
/** * Creates a new SOAPFault object initialized with the given reasonText and faultCode * * @param reasonText - the ReasonText/FaultString for the fault faultCode - the FaultCode for * the fault * @return: a SOAPFault object * @throws: SOAPException - if there is a SOAP error */ public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException { SOAPFault soapFault; if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) { soapFault = new SOAPFaultImpl(metaFactory.getSOAP12Factory() .createSOAPFault()); } else { soapFault = new SOAPFaultImpl(metaFactory.getSOAP11Factory() .createSOAPFault()); } soapFault.setFaultCode(faultCode); try { soapFault.addFaultReasonText(reasonText, Locale.getDefault()); } catch (UnsupportedOperationException e) { throw new SOAPException(e.getMessage()); } return soapFault; }
/** * Creates a new SOAPFault object initialized with the given reasonText and faultCode * * @param reasonText - the ReasonText/FaultString for the fault faultCode - the FaultCode for * the fault * @return: a SOAPFault object * @throws: SOAPException - if there is a SOAP error */ public SOAPFault createFault(String reasonText, QName faultCode) throws SOAPException { SOAPFault soapFault; if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) { soapFault = new SOAPFaultImpl(metaFactory.getSOAP12Factory() .createSOAPFault()); } else { soapFault = new SOAPFaultImpl(metaFactory.getSOAP11Factory() .createSOAPFault()); } soapFault.setFaultCode(faultCode); try { soapFault.addFaultReasonText(reasonText, Locale.getDefault()); } catch (UnsupportedOperationException e) { throw new SOAPException(e.getMessage()); } return soapFault; }
/** * Creates a new <code>SOAPFault</code> object and adds it to this <code>SOAPBody</code> * object. * * @return the new <code>SOAPFault</code> object * @throws SOAPException if there is a SOAP error */ public SOAPFault addFault() throws SOAPException { if (isBodyElementAdded) { throw new SOAPException("A SOAPBodyElement has been already added to this SOAPBody"); } org.apache.axiom.soap.SOAPFault fault = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPFault(omTarget); SOAPFaultImpl saajSOAPFault = new SOAPFaultImpl(fault); // set default fault code and string saajSOAPFault.setDefaults(); return saajSOAPFault; }
/** * Creates a new <code>SOAPFault</code> object and adds it to this <code>SOAPBody</code> * object. * * @return the new <code>SOAPFault</code> object * @throws SOAPException if there is a SOAP error */ public SOAPFault addFault() throws SOAPException { if (isBodyElementAdded) { throw new SOAPException("A SOAPBodyElement has been already added to this SOAPBody"); } org.apache.axiom.soap.SOAPFault fault = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPFault(omTarget); SOAPFaultImpl saajSOAPFault = new SOAPFaultImpl(fault); // set default fault code and string saajSOAPFault.setDefaults(); return saajSOAPFault; }
private void writeError(SOAPFactory factory, SoapOperationBinding binding, SOAPBody body, CougarException error) throws Exception { if (error != null) { SOAPFault soapFault = factory.createSOAPFault(body); if (error.getFault() != null) { createFaultCode(factory, soapFault, error.getFault()); createFaultString(factory, soapFault, error.getFault()); createFaultDetail(factory, soapFault, error.getFault(), binding); } } }
/** * Creates a new <code>SOAPFault</code> object and adds it to this <code>SOAPBody</code> object. * The new <code>SOAPFault</code> will have a <code>faultcode</code> element that is set to the * <code>faultCode</code> parameter and a <code>faultstring</code> set to * <code>faultstring</code> and localized to <code>locale</code>. * * @param faultCode a <code>QName</code> object giving the fault code to be * @param faultString a <code>String</code> giving an explanation of the fault * @param locale a <code>Locale</code> object indicating the native language of the * <ocde>faultString</code> * @return the new <code>SOAPFault</code> object * @throws SOAPException if there is a SOAP error */ public SOAPFault addFault(QName faultCode, String faultString, Locale locale) throws SOAPException { org.apache.axiom.soap.SOAPFault fault = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPFault(omTarget); SOAPFaultImpl faultImpl = new SOAPFaultImpl(fault); if (faultImpl != null) { faultImpl.setFaultCode(faultCode); if (locale != null) { faultImpl.setFaultString(faultString, locale); } else { faultImpl.setFaultString(faultString); } } return faultImpl; }