public void setFaultCodeValue(QName faultCodeValue) {

    if (soapVersion == SOAP11) {
      this.faultCodeValue = faultCodeValue;

    } else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(faultCodeValue.getNamespaceURI())
        && (SOAP12Constants.FAULT_CODE_DATA_ENCODING_UNKNOWN.equals(faultCodeValue.getLocalPart())
            || SOAP12Constants.FAULT_CODE_MUST_UNDERSTAND.equals(faultCodeValue.getLocalPart())
            || SOAP12Constants.FAULT_CODE_RECEIVER.equals(faultCodeValue.getLocalPart())
            || SOAP12Constants.FAULT_CODE_SENDER.equals(faultCodeValue.getLocalPart())
            || SOAP12Constants.FAULT_CODE_VERSION_MISMATCH.equals(faultCodeValue.getLocalPart()))) {

      this.faultCodeValue = faultCodeValue;

    } else {
      handleException("Invalid Fault code value for a SOAP 1.2 fault : " + faultCodeValue);
    }
  }
  public boolean mediate(MessageContext synCtx) {

    if (synCtx.getEnvironment().isDebugEnabled()) {
      if (super.divertMediationRoute(synCtx)) {
        return true;
      }
    }

    SynapseLog synLog = getLog(synCtx);

    if (synLog.isTraceOrDebugEnabled()) {
      synLog.traceOrDebug("Start : Fault mediator");

      if (synLog.isTraceTraceEnabled()) {
        synLog.traceTrace("Message : " + synCtx.getEnvelope());
      }
    }

    switch (soapVersion) {
      case SOAP11:
        makeSOAPFault(synCtx, SOAP11, synLog);
        break;
      case SOAP12:
        makeSOAPFault(synCtx, SOAP12, synLog);
        break;
      case POX:
        makePOXFault(synCtx, synLog);
        break;

      default:
        {
          // if this is a POX or REST message then make a POX fault
          if (synCtx.isDoingPOX() || synCtx.isDoingGET()) {

            makePOXFault(synCtx, synLog);

          } else {

            // determine from current message's SOAP envelope namespace
            SOAPEnvelope envelop = synCtx.getEnvelope();
            if (envelop != null) {

              if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(
                  envelop.getNamespace().getNamespaceURI())) {
                makeSOAPFault(synCtx, SOAP12, synLog);

              } else {
                makeSOAPFault(synCtx, SOAP11, synLog);
              }

            } else {
              // default to SOAP 11
              makeSOAPFault(synCtx, SOAP11, synLog);
            }
          }
        }
    }

    final Pipe pipe =
        (Pipe)
            (((Axis2MessageContext) synCtx))
                .getAxis2MessageContext()
                .getProperty(PassThroughConstants.PASS_THROUGH_PIPE);
    if (pipe != null) {
      // cleaning the OUTPUT PIPE with older references
      // if there is a [protocal violation when sending out message etc.]
      pipe.getBuffer().clear();
      pipe.resetOutputStream();
    }

    // if the message has to be marked as a response mark it as response
    if (markAsResponse) {
      synCtx.setResponse(true);
      synCtx.setTo(synCtx.getReplyTo());
    }

    return true;
  }