Java 类javax.xml.soap.SOAPFault 实例源码

项目:OpenJSharp    文件:SOAP11Fault.java   
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
项目:OpenJSharp    文件:SOAP12Fault.java   
SOAP12Fault(SOAPFault fault) {
    code = new CodeType(fault.getFaultCodeAsQName());
    try {
        fillFaultSubCodes(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    reason = new ReasonType(fault.getFaultString());
    role = fault.getFaultRole();
    node = fault.getFaultNode();
    if (fault.getDetail() != null) {
        detail = new DetailType();
        Iterator iter = fault.getDetail().getDetailEntries();
        while(iter.hasNext()){
            Element fd = (Element)iter.next();
            detail.getDetails().add(fd);
        }
    }
}
项目:OpenJSharp    文件:SOAP12Fault.java   
/**
 * Adds Fault subcodes from {@link SOAPFault} to {@link #code}
 */
private void fillFaultSubCodes(SOAPFault fault) throws SOAPException {
    Iterator subcodes = fault.getFaultSubcodes();
    SubcodeType firstSct = null;
    while(subcodes.hasNext()){
        QName subcode = (QName)subcodes.next();
        if(firstSct == null){
            firstSct = new SubcodeType(subcode);
            code.setSubcode(firstSct);
            continue;
        }
        SubcodeType nextSct = new SubcodeType(subcode);
        firstSct.setSubcode(nextSct);
        firstSct = nextSct;
    }
}
项目:openjdk-jdk10    文件:SOAP11Fault.java   
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
项目:openjdk-jdk10    文件:SOAP12Fault.java   
SOAP12Fault(SOAPFault fault) {
    code = new CodeType(fault.getFaultCodeAsQName());
    try {
        fillFaultSubCodes(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    reason = new ReasonType(fault.getFaultString());
    role = fault.getFaultRole();
    node = fault.getFaultNode();
    if (fault.getDetail() != null) {
        detail = new DetailType();
        Iterator iter = fault.getDetail().getDetailEntries();
        while(iter.hasNext()){
            Element fd = (Element)iter.next();
            detail.getDetails().add(fd);
        }
    }
}
项目:openjdk-jdk10    文件:SOAP12Fault.java   
/**
 * Adds Fault subcodes from {@link SOAPFault} to {@link #code}
 */
private void fillFaultSubCodes(SOAPFault fault) throws SOAPException {
    Iterator subcodes = fault.getFaultSubcodes();
    SubcodeType firstSct = null;
    while(subcodes.hasNext()){
        QName subcode = (QName)subcodes.next();
        if(firstSct == null){
            firstSct = new SubcodeType(subcode);
            code.setSubcode(firstSct);
            continue;
        }
        SubcodeType nextSct = new SubcodeType(subcode);
        firstSct.setSubcode(nextSct);
        firstSct = nextSct;
    }
}
项目:openjdk-jdk10    文件:BodyImpl.java   
@Override
public SOAPFault addFault() throws SOAPException {
    if (hasFault()) {
        log.severe("SAAJ0110.impl.fault.already.exists");
        throw new SOAPExceptionImpl("Error: Fault already exists");
    }

    fault = createFaultElement();

    addNode(fault);

    fault.setFaultCode(getDefaultFaultCode());
    fault.setFaultString("Fault string, and possibly fault code, not set");

    return fault;
}
项目:openjdk9    文件:SOAP11Fault.java   
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
项目:openjdk9    文件:SOAP12Fault.java   
SOAP12Fault(SOAPFault fault) {
    code = new CodeType(fault.getFaultCodeAsQName());
    try {
        fillFaultSubCodes(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    reason = new ReasonType(fault.getFaultString());
    role = fault.getFaultRole();
    node = fault.getFaultNode();
    if (fault.getDetail() != null) {
        detail = new DetailType();
        Iterator iter = fault.getDetail().getDetailEntries();
        while(iter.hasNext()){
            Element fd = (Element)iter.next();
            detail.getDetails().add(fd);
        }
    }
}
项目:openjdk9    文件:SOAP12Fault.java   
/**
 * Adds Fault subcodes from {@link SOAPFault} to {@link #code}
 */
private void fillFaultSubCodes(SOAPFault fault) throws SOAPException {
    Iterator subcodes = fault.getFaultSubcodes();
    SubcodeType firstSct = null;
    while(subcodes.hasNext()){
        QName subcode = (QName)subcodes.next();
        if(firstSct == null){
            firstSct = new SubcodeType(subcode);
            code.setSubcode(firstSct);
            continue;
        }
        SubcodeType nextSct = new SubcodeType(subcode);
        firstSct.setSubcode(nextSct);
        firstSct = nextSct;
    }
}
项目:sam-elle    文件:EditTerminalClient.java   
public void callWebService(String iccid, String businessValue) throws SOAPException, IOException, XWSSecurityException, Exception {
    SOAPMessage request = createTerminalRequest(iccid, businessValue);
    request = secureMessage(request);

    // TODO
    logger.info("Edit Terminal Request: ");
    request.writeTo(System.out);
    System.out.println("");

    SOAPConnection connection = connectionFactory.createConnection();
    SOAPMessage response = connection.call(request, url);
    // TODO
    logger.info("Edit Terminal Response: ");
    response.writeTo(System.out);
    System.out.println("");

    if (!response.getSOAPBody().hasFault()) {
        writeTerminalResponse(response);
    } else {
        SOAPFault fault = response.getSOAPBody().getFault();
        logger.error("Received SOAP Fault");
        logger.error("SOAP Fault Code :" + fault.getFaultCode());
        logger.error("SOAP Fault String :" + fault.getFaultString());
    }
}
项目:sam-elle    文件:GetTerminalsByMsisdnClient.java   
public String callWebService(String msisdn) throws SOAPException, IOException, XWSSecurityException, GetTermalIccidException {
    SOAPMessage request = createTerminalRequest(msisdn);
    request = secureMessage(request);

    // TODO
    logger.info("Get Terminals by msisdn Request: ");
    request.writeTo(System.out);
    System.out.println("");

    SOAPConnection connection = connectionFactory.createConnection();
    SOAPMessage response = connection.call(request, url);
    // TODO
    logger.info("Get Terminals by msisdn Response: ");
    response.writeTo(System.out);
    System.out.println("");

    if (!response.getSOAPBody().hasFault()) {
        return writeTerminalResponse(response);
    } else {
        SOAPFault fault = response.getSOAPBody().getFault();
        logger.error("Received SOAP Fault");
        logger.error("SOAP Fault Code :" + fault.getFaultCode());
        logger.error("SOAP Fault String :" + fault.getFaultString());
        throw new GetTermalIccidException(fault.getFaultCode() + "," + fault.getFaultString());
    }
}
项目:hermes    文件:SOAPResponse.java   
/**
 * Adds a SOAP fault to the SOAP message of this response.
 * 
 * @param code the fault code.
 * @param actor the fault actor.
 * @param desc the fault description.
 * @return the SOAP fault which has been added to the SOAP message. null if
 *         there is no SOAP message in this response or the fault has
 *         already been added.
 * @throws SOAPException a SOAP error occurred when adding the the fault.
 */
public SOAPFault addFault(String code, String actor, String desc)
        throws SOAPException {
    SOAPMessage msg = getMessage();
    if (msg != null) {
        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
        SOAPBody body = env.getBody();
        if (body != null && !body.hasFault()) {
            SOAPFault fault = body.addFault();
            if (code != null) {
                fault.setFaultCode(env.getElementName().getPrefix() + ":"
                        + code);
            }
            if (actor != null) {
                fault.setFaultActor(actor);
            }
            if (desc != null) {
                fault.setFaultString(desc);
            }
            return fault;
        }
    }
    return null;
}
项目:engerek    文件:ModelWebServiceRaw.java   
@Override
public DOMSource invoke(DOMSource request) {
    try {
        return invokeAllowingFaults(request);
    } catch (FaultMessage faultMessage) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault();
            soapFault.setFaultCode(SOAP11_FAULTCODE_SERVER);           // todo here is a constant until we have a mechanism to determine the correct value (client / server)
            soapFault.setFaultString(faultMessage.getMessage());
            Detail detail = soapFault.addDetail();
            serializeFaultMessage(detail, faultMessage);
            // fault actor?
            // stack trace of the outer exception (FaultMessage) is unimportant, because it is always created at one place
            // todo consider providing stack trace of the inner exception
            //Detail detail = soapFault.addDetail();
            //detail.setTextContent(getStackTraceAsString(faultMessage));
            throw new SOAPFaultException(soapFault);
        } catch (SOAPException e) {
            throw new RuntimeException("SOAP Exception: " + e.getMessage(), e);
        }
    }
}
项目:engerek    文件:ReportWebServiceRaw.java   
@Override
public DOMSource invoke(DOMSource request) {
    try {
        return invokeAllowingFaults(request);
    } catch (FaultMessage faultMessage) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault();
            soapFault.setFaultCode(SOAP11_FAULTCODE_SERVER);           // todo here is a constant until we have a mechanism to determine the correct value (client / server)
            soapFault.setFaultString(faultMessage.getMessage());
            Detail detail = soapFault.addDetail();
            serializeFaultMessage(detail, faultMessage);
            // fault actor?
            // stack trace of the outer exception (FaultMessage) is unimportant, because it is always created at one place
            // todo consider providing stack trace of the inner exception
            //Detail detail = soapFault.addDetail();
            //detail.setTextContent(getStackTraceAsString(faultMessage));
            throw new SOAPFaultException(soapFault);
        } catch (SOAPException e) {
            throw new RuntimeException("SOAP Exception: " + e.getMessage(), e);
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SOAP11Fault.java   
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SOAP12Fault.java   
SOAP12Fault(SOAPFault fault) {
    code = new CodeType(fault.getFaultCodeAsQName());
    try {
        fillFaultSubCodes(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    reason = new ReasonType(fault.getFaultString());
    role = fault.getFaultRole();
    node = fault.getFaultNode();
    if (fault.getDetail() != null) {
        detail = new DetailType();
        Iterator iter = fault.getDetail().getDetailEntries();
        while(iter.hasNext()){
            Element fd = (Element)iter.next();
            detail.getDetails().add(fd);
        }
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SOAP12Fault.java   
/**
 * Adds Fault subcodes from {@link SOAPFault} to {@link #code}
 */
private void fillFaultSubCodes(SOAPFault fault) throws SOAPException {
    Iterator subcodes = fault.getFaultSubcodes();
    SubcodeType firstSct = null;
    while(subcodes.hasNext()){
        QName subcode = (QName)subcodes.next();
        if(firstSct == null){
            firstSct = new SubcodeType(subcode);
            code.setSubcode(firstSct);
            continue;
        }
        SubcodeType nextSct = new SubcodeType(subcode);
        firstSct.setSubcode(nextSct);
        firstSct = nextSct;
    }
}
项目:sam-elle    文件:EditTerminalClient.java   
public void callWebService(String iccid, String businessValue) throws SOAPException, IOException, XWSSecurityException, Exception {
    SOAPMessage request = createTerminalRequest(iccid, businessValue);
    request = secureMessage(request);

    // TODO
    logger.info("Edit Terminal Request: ");
    request.writeTo(System.out);
    System.out.println("");

    SOAPConnection connection = connectionFactory.createConnection();
    SOAPMessage response = connection.call(request, url);
    // TODO
    logger.info("Edit Terminal Response: ");
    response.writeTo(System.out);
    System.out.println("");

    if (!response.getSOAPBody().hasFault()) {
        writeTerminalResponse(response);
    } else {
        SOAPFault fault = response.getSOAPBody().getFault();
        logger.error("Received SOAP Fault");
        logger.error("SOAP Fault Code :" + fault.getFaultCode());
        logger.error("SOAP Fault String :" + fault.getFaultString());
    }
}
项目:sam-elle    文件:GetTerminalsByMsisdnClient.java   
public String callWebService(String msisdn) throws SOAPException, IOException, XWSSecurityException, GetTermalIccidException {
    SOAPMessage request = createTerminalRequest(msisdn);
    request = secureMessage(request);

    // TODO
    logger.info("Get Terminals by msisdn Request: ");
    request.writeTo(System.out);
    System.out.println("");

    SOAPConnection connection = connectionFactory.createConnection();
    SOAPMessage response = connection.call(request, url);
    // TODO
    logger.info("Get Terminals by msisdn Response: ");
    response.writeTo(System.out);
    System.out.println("");

    if (!response.getSOAPBody().hasFault()) {
        return writeTerminalResponse(response);
    } else {
        SOAPFault fault = response.getSOAPBody().getFault();
        logger.error("Received SOAP Fault");
        logger.error("SOAP Fault Code :" + fault.getFaultCode());
        logger.error("SOAP Fault String :" + fault.getFaultString());
        throw new GetTermalIccidException(fault.getFaultCode() + "," + fault.getFaultString());
    }
}
项目:jbossws-cxf    文件:ProviderImpl.java   
public SOAPMessage invoke(SOAPMessage requestSoapMessage)
   {
      SOAPFault theSOAPFault;
      try {
         theSOAPFault = SOAPFactory.newInstance().createFault();
         Detail soapFaultDetail = theSOAPFault.addDetail();
         SOAPElement myFaultElement = soapFaultDetail.addChildElement(new QName("http://www.my-company.it/ws/my-test", "MyWSException"));
         SOAPElement myMessageElement = myFaultElement.addChildElement(new QName("http://www.my-company.it/ws/my-test", "message"));
//         myMessageElement.setNodeValue("This is a faked error"); //wrong: myMessageElement is not a text node
         myMessageElement.setValue("This is a faked error"); //right: this creates a text node and gives it a text value
      } catch (SOAPException se) {
         se.printStackTrace();
         throw new RuntimeException("Something unexpected happened!");
      }
      throw new SOAPFaultException(theSOAPFault);
   }
项目:jbossws-cxf    文件:ClientSOAPHandler.java   
protected boolean handleOutbound(final SOAPMessageContext msgContext)
{
   try
   {
      SOAPFault fault = null;
      MessageFactory factory = MessageFactory.newInstance(); 
      SOAPMessage resMessage = factory.createMessage();
      fault = resMessage.getSOAPBody().addFault();
      fault.setFaultString("this is an exception thrown by client outbound");
      throw new SOAPFaultException(fault);
   }
   catch (SOAPException e)
   {
      //ignore
   }
   return true;
}
项目:jbossws-cxf    文件:EndpointImpl.java   
public void throwSoapFaultException()
{
   // This should be thrown as-is
   try
   {
      SOAPFactory factory = SOAPFactory.newInstance();
      SOAPFault fault = factory.createFault("this is a fault string!", SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
      fault.setFaultActor("mr.actor");
      fault.addDetail().addChildElement("test");
      throw new SOAPFaultException(fault);
   }
   catch (SOAPException s)
   {
      throw new RuntimeException(s);
   }
}
项目:jbossws-cxf    文件:JBWS3945EndpointImpl.java   
public void throwSoapFaultException()
{
   try
   {
      MessageContext ctx = context.getMessageContext();
      ctx.put(MessageContext.HTTP_RESPONSE_CODE, 400);

      SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
      SOAPFault fault = factory.createFault();
      fault.addFaultReasonText("this is a fault string!", Locale.ITALIAN);
      fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
      fault.setFaultActor("mr.actor");
      fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "AnException"));
      fault.addDetail().addChildElement("test");
      throw new SOAPFaultException(fault);
   }
   catch (Exception s)
   {
      throw new RuntimeException(s);
   }
}
项目:jbossws-cxf    文件:SOAP12EndpointImpl.java   
public void throwSoapFaultException()
{
   // This should be thrown as-is
   try
   {
      SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
      SOAPFault fault = factory.createFault();
      fault.addFaultReasonText("this is a fault string!", Locale.ITALIAN);
      fault.setFaultCode(SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
      fault.setFaultActor("mr.actor");
      fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "NullPointerException"));
      fault.addDetail().addChildElement("test");
      throw new SOAPFaultException(fault);
   }
   catch (SOAPException s)
   {
      throw new RuntimeException(s);
   }
}
项目:jbossws-cxf    文件:WebMethodTestCase.java   
@Test
@RunAsClient
public void testIllegalMessageAccess() throws Exception
{
   MessageFactory msgFactory = MessageFactory.newInstance();
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();

   String reqEnv =
      "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
      " <env:Header/>" +
      " <env:Body>" +
      "  <ns1:noWebMethod xmlns:ns1='" + targetNS + "'>" +
      "   <String_1>Hello</String_1>" +
      "  </ns1:noWebMethod>" +
      " </env:Body>" +
      "</env:Envelope>";
   SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));

   URL epURL = new URL(baseURL + "/TestService");
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   SOAPFault soapFault = resMsg.getSOAPBody().getFault();
   assertNotNull("Expected SOAPFault", soapFault);

   String faultString = soapFault.getFaultString();
   assertTrue(faultString, faultString.indexOf("noWebMethod") > 0);
}
项目:SonosNPROneServer    文件:SonosService.java   
private static void throwSoapFault(String faultMessage, String ExceptionDetail, String SonosError) throws RuntimeException {
SOAPFault soapFault;
try {
          soapFault = SOAPFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createFault();
          soapFault.setFaultString(faultMessage);
          soapFault.setFaultCode(new QName(faultMessage));

          if(!ExceptionDetail.isEmpty() && !SonosError.isEmpty()) {            
            Detail detail = soapFault.addDetail();
            SOAPElement el1 = detail.addChildElement("ExceptionDetail");
            el1.setValue(ExceptionDetail);
           SOAPElement el = detail.addChildElement("SonosError");
           el.setValue(SonosError);             
          }

      } catch (Exception e2) {
          throw new RuntimeException("Problem processing SOAP Fault on service-side." + e2.getMessage());
      }
          throw new SOAPFaultException(soapFault);

  }
项目:infobip-open-jdk-8    文件:SOAP11Fault.java   
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
项目:infobip-open-jdk-8    文件:SOAP12Fault.java   
SOAP12Fault(SOAPFault fault) {
    code = new CodeType(fault.getFaultCodeAsQName());
    try {
        fillFaultSubCodes(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    reason = new ReasonType(fault.getFaultString());
    role = fault.getFaultRole();
    node = fault.getFaultNode();
    if (fault.getDetail() != null) {
        detail = new DetailType();
        Iterator iter = fault.getDetail().getDetailEntries();
        while(iter.hasNext()){
            Element fd = (Element)iter.next();
            detail.getDetails().add(fd);
        }
    }
}
项目:infobip-open-jdk-8    文件:SOAP12Fault.java   
/**
 * Adds Fault subcodes from {@link SOAPFault} to {@link #code}
 */
private void fillFaultSubCodes(SOAPFault fault) throws SOAPException {
    Iterator subcodes = fault.getFaultSubcodes();
    SubcodeType firstSct = null;
    while(subcodes.hasNext()){
        QName subcode = (QName)subcodes.next();
        if(firstSct == null){
            firstSct = new SubcodeType(subcode);
            code.setSubcode(firstSct);
            continue;
        }
        SubcodeType nextSct = new SubcodeType(subcode);
        firstSct.setSubcode(nextSct);
        firstSct = nextSct;
    }
}
项目:switchyard    文件:SOAPFaultInfo.java   
/**
 * @param soapMessage the soap message to copy fault information from
 * @throws SOAPException if any
 */
public void copyFaultInfo(SOAPMessage soapMessage) throws SOAPException {
    SOAPFault fault = soapMessage.getSOAPBody().getFault();
    setActor(fault.getFaultActor());
    setCode(fault.getFaultCode());
    setPrefix(fault.getFaultCodeAsName().getPrefix());
    setCodeAsQName(fault.getFaultCodeAsQName());
    setString(fault.getFaultString());
    setStringLocale(fault.getFaultStringLocale());
    if (fault.hasDetail()) {
        setDetail(fault.getDetail());
    }

    // SOAP 1.2 specifics
    if (SOAPUtil.isSOAP12(soapMessage)) {
        setReasonLocales(fault.getFaultReasonLocales());
        Iterator<Locale> locales = fault.getFaultReasonLocales();
        while (locales.hasNext()) {
            Locale locale = locales.next();
            addReasonText(locale, fault.getFaultReasonText(locale));
        }
        setRole(fault.getFaultRole());
        setSubcodes(fault.getFaultSubcodes());
    }
}
项目:switchyard    文件:SOAPUtil.java   
private static SOAPFault createFault(final Throwable th, SOAPFactory factory, final QName faultQname) throws SOAPException {
    if (LOGGER.isDebugEnabled()) {
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw);
        th.printStackTrace(pw);
        pw.flush();
        pw.close();
        LOGGER.debug(sw.toString());
    }
    String message = th.getMessage();
    if (message == null) {
        message = th.toString();
    }
    SOAPFault fault = factory.createFault(message, faultQname);
    return fault;
}
项目:midpoint    文件:ModelWebServiceRaw.java   
@Override
public DOMSource invoke(DOMSource request) {
    try {
        return invokeAllowingFaults(request);
    } catch (FaultMessage faultMessage) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault();
            soapFault.setFaultCode(SOAP11_FAULTCODE_SERVER);           // todo here is a constant until we have a mechanism to determine the correct value (client / server)
            soapFault.setFaultString(faultMessage.getMessage());
            Detail detail = soapFault.addDetail();
            serializeFaultMessage(detail, faultMessage);
            // fault actor?
            // stack trace of the outer exception (FaultMessage) is unimportant, because it is always created at one place
            // todo consider providing stack trace of the inner exception
            //Detail detail = soapFault.addDetail();
            //detail.setTextContent(getStackTraceAsString(faultMessage));
            throw new SOAPFaultException(soapFault);
        } catch (SOAPException e) {
            throw new RuntimeException("SOAP Exception: " + e.getMessage(), e);
        }
    }
}
项目:midpoint    文件:ReportWebServiceRaw.java   
@Override
public DOMSource invoke(DOMSource request) {
    try {
        return invokeAllowingFaults(request);
    } catch (FaultMessage faultMessage) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault();
            soapFault.setFaultCode(SOAP11_FAULTCODE_SERVER);           // todo here is a constant until we have a mechanism to determine the correct value (client / server)
            soapFault.setFaultString(faultMessage.getMessage());
            Detail detail = soapFault.addDetail();
            serializeFaultMessage(detail, faultMessage);
            // fault actor?
            // stack trace of the outer exception (FaultMessage) is unimportant, because it is always created at one place
            // todo consider providing stack trace of the inner exception
            //Detail detail = soapFault.addDetail();
            //detail.setTextContent(getStackTraceAsString(faultMessage));
            throw new SOAPFaultException(soapFault);
        } catch (SOAPException e) {
            throw new RuntimeException("SOAP Exception: " + e.getMessage(), e);
        }
    }
}
项目:OLD-OpenJDK8    文件:SOAP11Fault.java   
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
项目:OLD-OpenJDK8    文件:SOAP12Fault.java   
SOAP12Fault(SOAPFault fault) {
    code = new CodeType(fault.getFaultCodeAsQName());
    try {
        fillFaultSubCodes(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    reason = new ReasonType(fault.getFaultString());
    role = fault.getFaultRole();
    node = fault.getFaultNode();
    if (fault.getDetail() != null) {
        detail = new DetailType();
        Iterator iter = fault.getDetail().getDetailEntries();
        while(iter.hasNext()){
            Element fd = (Element)iter.next();
            detail.getDetails().add(fd);
        }
    }
}
项目:OLD-OpenJDK8    文件:SOAP12Fault.java   
/**
 * Adds Fault subcodes from {@link SOAPFault} to {@link #code}
 */
private void fillFaultSubCodes(SOAPFault fault) throws SOAPException {
    Iterator subcodes = fault.getFaultSubcodes();
    SubcodeType firstSct = null;
    while(subcodes.hasNext()){
        QName subcode = (QName)subcodes.next();
        if(firstSct == null){
            firstSct = new SubcodeType(subcode);
            code.setSubcode(firstSct);
            continue;
        }
        SubcodeType nextSct = new SubcodeType(subcode);
        firstSct.setSubcode(nextSct);
        firstSct = nextSct;
    }
}
项目:juddi    文件:MapUDDIv2Tov3.java   
private static List<Result> MapFault(SOAPFault result) {
        List<Result> r = new ArrayList<Result>();
        if (result == null) {
                return r;
        }
        if (result.getDetail() != null) {
                while (result.getDetail().getDetailEntries().hasNext()) {
                        Object next = result.getDetail().getDetailEntries().next();
                        if (next instanceof DispositionReport) {

                                DispositionReport z = (DispositionReport) next;
                                r.addAll(MapResult(z.getFaultInfo().getResult()));

                        }
                        logger.warn("unable to parse fault detail, type:" + next.getClass().getCanonicalName() + " " + next.toString());
                }
        }
        return r;
}
项目:wso2-axis2    文件:XMLFaultTest.java   
/**
 * Test Custom FaultQName for SOAP 1.1
 * @throws Exception
 */
public void testCustomFault11() throws Exception {
    MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
    SOAPMessage sm = mf.createMessage();
    SOAPBody body = sm.getSOAPBody();
    SOAPFault fault = body.addFault(CUSTOM, "Custom Fault");

    XMLFault xmlFault = XMLFaultUtils.createXMLFault(fault);

    assertTrue(xmlFault != null);

    XMLFaultReason reason = xmlFault.getReason();
    assertTrue(reason != null);
    assertTrue(reason.getText().equals("Custom Fault"));

    XMLFaultCode code = xmlFault.getCode();
    assertTrue(code != null);

    QName codeQName = code.toQName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
    assertTrue("Expected QName = " + CUSTOM + " but received = " + codeQName, codeQName.equals(CUSTOM));

}
项目:wso2-axis2    文件:XMLFaultTest.java   
/**
 * Test Custom FaultQName for SOAP 1.2
 * @throws Exception
 */
public void testCustomFault12() throws Exception {
    MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage sm = mf.createMessage();
    SOAPBody body = sm.getSOAPBody();

    try {
        SOAPFault fault = body.addFault(CUSTOM, "Custom Fault");
        fail("Expected Failure, custom fault codes are not supported with SOAP 1.2");
    } catch (SOAPException e) {
        // Expected...
    } catch (Throwable t) {
        fail("Expected different failure, received: " + t);
    }

}