Java Code Examples for javax.xml.soap.SOAPFault#setFaultString()

The following examples show how to use javax.xml.soap.SOAPFault#setFaultString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BodyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPFault addFault(
     QName faultCode,
     String faultString,
     Locale locale)
     throws SOAPException {

     SOAPFault fault = addFault();
     fault.setFaultCode(faultCode);
     fault.setFaultString(faultString, locale);
     return fault;
 }
 
Example 2
Source File: BodyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SOAPFault addFault(
    Name faultCode,
    String faultString,
    Locale locale)
    throws SOAPException {

    SOAPFault fault = addFault();
    fault.setFaultCode(faultCode);
    fault.setFaultString(faultString, locale);
    return fault;
}
 
Example 3
Source File: SecurityTokenServiceImpl.java    From steady with Apache License 2.0 5 votes vote down vote up
private void throwUnsupportedOperation(String string) {
    try {
        SOAPFault fault = SAAJFactoryResolver.createSOAPFactory(null).createFault();
        fault.setFaultString("Unsupported operation " + string);
        throw new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new Fault(e);
    }
}
 
Example 4
Source File: WsaTubeHelper.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
    QName subcode = addVer.mapRequiredTag;
    QName subsubcode = addVer.mapRequiredTag;
    String faultstring = addVer.getMapRequiredText();

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
Example 5
Source File: SecurityTokenServiceImpl.java    From steady with Apache License 2.0 5 votes vote down vote up
private void throwUnsupportedOperation(String string) {
    try {
        SOAPFault fault = SAAJFactoryResolver.createSOAPFactory(null).createFault();
        fault.setFaultString("Unsupported operation " + string);
        throw new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new Fault(e);
    }
}
 
Example 6
Source File: EndpointArgumentsBuilder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private SOAPFaultException createDuplicateHeaderException() {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault();
        fault.setFaultCode(soapVersion.faultCodeClient);
        fault.setFaultString(ServerMessages.DUPLICATE_PORT_KNOWN_HEADER(headerName));
        return new SOAPFaultException(fault);
    } catch(SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example 7
Source File: SecurityTokenServiceImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void throwUnsupportedOperation(String string) {
    try {
        SOAPFault fault = SAAJFactoryResolver.createSOAPFactory(null).createFault();
        fault.setFaultString("Unsupported operation " + string);
        throw new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new Fault(e);
    }
}
 
Example 8
Source File: MUTube.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param notUnderstoodHeaders
 * @return SOAPfaultException with SOAPFault representing the MustUnderstand SOAP Fault.
 *         notUnderstoodHeaders are added in the fault detail.
 */
final SOAPFaultException createMUSOAPFaultException(Set<QName> notUnderstoodHeaders) {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault(
            MUST_UNDERSTAND_FAULT_MESSAGE_STRING,
            soapVersion.faultCodeMustUnderstand);
        fault.setFaultString("MustUnderstand headers:" +
            notUnderstoodHeaders + " are not understood");
        return new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example 9
Source File: EndpointArgumentsBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private SOAPFaultException createDuplicateHeaderException() {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault();
        fault.setFaultCode(soapVersion.faultCodeClient);
        fault.setFaultString(ServerMessages.DUPLICATE_PORT_KNOWN_HEADER(headerName));
        return new SOAPFaultException(fault);
    } catch(SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example 10
Source File: MUTube.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param notUnderstoodHeaders
 * @return SOAPfaultException with SOAPFault representing the MustUnderstand SOAP Fault.
 *         notUnderstoodHeaders are added in the fault detail.
 */
final SOAPFaultException createMUSOAPFaultException(Set<QName> notUnderstoodHeaders) {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault(
            MUST_UNDERSTAND_FAULT_MESSAGE_STRING,
            soapVersion.faultCodeMustUnderstand);
        fault.setFaultString("MustUnderstand headers:" +
            notUnderstoodHeaders + " are not understood");
        return new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example 11
Source File: ResponseBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private SOAPFaultException createDuplicateHeaderException() {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault();
        fault.setFaultCode(soapVersion.faultCodeServer);
        fault.setFaultString(ServerMessages.DUPLICATE_PORT_KNOWN_HEADER(headerName));
        return new SOAPFaultException(fault);
    } catch(SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example 12
Source File: SOAPFaultFactory.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static SOAPFaultException newSOAPFaultException(String reasonText, Throwable cause) {
   try {
      SOAPFactory factory = SOAPFactory.newInstance();
      SOAPFault soapFault = factory.createFault();
      soapFault.setFaultString(reasonText);
      SOAPFaultException except = new SOAPFaultException(soapFault);
      except.initCause(cause);
      return except;
   } catch (SOAPException var5) {
      throw new IllegalArgumentException(var5);
   }
}
 
Example 13
Source File: SOAPFaultFactory.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static SOAPFaultException newSOAPFaultException(String reasonText, Throwable cause) {
   try {
      SOAPFactory factory = SOAPFactory.newInstance();
      SOAPFault soapFault = factory.createFault();
      soapFault.setFaultString(reasonText);
      SOAPFaultException except = new SOAPFaultException(soapFault);
      except.initCause(cause);
      return except;
   } catch (SOAPException var5) {
      throw new IllegalArgumentException(var5);
   }
}
 
Example 14
Source File: ResponseBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private SOAPFaultException createDuplicateHeaderException() {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault();
        fault.setFaultCode(soapVersion.faultCodeServer);
        fault.setFaultString(ServerMessages.DUPLICATE_PORT_KNOWN_HEADER(headerName));
        return new SOAPFaultException(fault);
    } catch(SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example 15
Source File: WsaTubeHelper.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
    QName name = e.getProblemHeader();
    QName subsubcode = e.getSubsubcode();
    QName subcode = av.invalidMapTag;
    String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getInvalidMapDetail(name, fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
Example 16
Source File: WsaTubeHelper.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
    QName name = e.getProblemHeader();
    QName subsubcode = e.getSubsubcode();
    QName subcode = av.invalidMapTag;
    String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getInvalidMapDetail(name, fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
Example 17
Source File: WsaTubeHelper.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
    QName subcode = addVer.mapRequiredTag;
    QName subsubcode = addVer.mapRequiredTag;
    String faultstring = addVer.getMapRequiredText();

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
Example 18
Source File: MUTube.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param notUnderstoodHeaders
 * @return SOAPfaultException with SOAPFault representing the MustUnderstand SOAP Fault.
 *         notUnderstoodHeaders are added in the fault detail.
 */
final SOAPFaultException createMUSOAPFaultException(Set<QName> notUnderstoodHeaders) {
    try {
        SOAPFault fault = soapVersion.getSOAPFactory().createFault(
            MUST_UNDERSTAND_FAULT_MESSAGE_STRING,
            soapVersion.faultCodeMustUnderstand);
        fault.setFaultString("MustUnderstand headers:" +
            notUnderstoodHeaders + " are not understood");
        return new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
Example 19
Source File: TestSOAPHandler.java    From cxf with Apache License 2.0 4 votes vote down vote up
private SOAPFaultException createSOAPFaultException(String faultString) throws SOAPException {
    SOAPFault fault = SOAPFactory.newInstance().createFault();
    fault.setFaultString(faultString);
    SAAJUtils.setFaultCode(fault, new QName("http://cxf.apache.org/faultcode", "Server"));
    return new SOAPFaultException(fault);
}
 
Example 20
Source File: AbstractSoapEncoder.java    From arctic-sea with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a SOAPFault element from SOS internal fault
 *
 * @param fault
 *            SOAPFault element
 * @param soapFault
 *            SOS internal fault
 *
 * @throws SOAPException
 *             if an error occurs.
 *
 * @deprecated javax.xml.soap.* is no longer supported from 8.0 because it
 *             was removed from Java
 */
@Deprecated
protected void createSOAPFault(SOAPFault fault, SoapFault soapFault) throws SOAPException {
    fault.setFaultCode(soapFault.getFaultCode());
    fault.setFaultString(soapFault.getFaultReason(), soapFault.getLocale());
    if (soapFault.getDetailText() != null) {
        fault.addDetail()
                .setTextContent(soapFault.getDetailText());
    }
}