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

项目: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);
    }
}
项目: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);
    }
}
项目: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);
    }
}
项目: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);
    }
}
项目:jbossws-cxf    文件:JBWS1815TestCase.java   
@Test
@RunAsClient
public void testProviderMessage() throws Exception
{
   SOAPMessage reqMsg = getRequestMessage();
   URL epURL = new URL(baseURL + "/jaxws-jbws1815/ProviderImpl");
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
   Detail detail = resEnv.getBody().getFault().getDetail();
   assertNotNull(detail);
   SOAPElement exception = (SOAPElement)detail.getDetailEntries().next();
   assertNotNull(exception);
   assertEquals("MyWSException", exception.getElementQName().getLocalPart());
   assertEquals("http://www.my-company.it/ws/my-test", exception.getElementQName().getNamespaceURI());
   SOAPElement message = (SOAPElement)exception.getChildElements().next();
   assertNotNull(message);
   assertEquals("message", message.getNodeName());
   assertEquals("This is a faked error", message.getValue());
}
项目: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);
   }
项目: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);
    }
}
项目: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);
    }
}
项目:wso2-axis2    文件:SOAPFaultImpl.java   
public Detail addDetail() throws SOAPException {
    if (isDetailAdded) {
        throw new SOAPException("This SOAPFault already contains a Detail element. " +
                "Please remove the existing Detail element before " +
                "calling addDetail()");
    }

    SOAPFaultDetail omDetail;
    SOAPFactory factory = (SOAPFactory)this.element.getOMFactory();
    if (factory instanceof SOAP11Factory) {
        omDetail = new SOAP11FaultDetailImpl(this.fault,
                                             factory);
    } else {
        omDetail = new SOAP12FaultDetailImpl(this.fault,
                                             factory);
    }
    Detail saajDetail = new DetailImpl(omDetail);
    ((NodeImpl)fault.getDetail()).setUserData(SAAJ_NODE, saajDetail, null);
    isDetailAdded = true;
    return saajDetail;
}
项目:wso2-axis2    文件:SOAPElementImpl.java   
/**
 * Sets the encoding style for this SOAPElement object to one specified.
 *
 * @param encodingStyle - a String giving the encoding style
 * @throws IllegalArgumentException
 *          - if there was a problem in the encoding style being set. SOAPException - if setting
 *          the encodingStyle is invalid for this SOAPElement.
 */
public void setEncodingStyle(String encodingStyle) throws SOAPException {
    if (this.element.getOMFactory() instanceof SOAP11Factory) {
        try {
            URI uri = new URI(encodingStyle);
            if (!(this instanceof SOAPEnvelope)) {
                if (!encodingStyle.equals(SOAPConstants.URI_NS_SOAP_ENCODING)) {
                    throw new IllegalArgumentException(
                            "Invalid Encoding style : " + encodingStyle);
                }
            }
            this.encodingStyle = encodingStyle;
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Invalid Encoding style : "
                    + encodingStyle + ":" + e);
        }
    } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
        if (this instanceof SOAPHeader || this instanceof SOAPBody ||
                this instanceof SOAPFault ||
                this instanceof SOAPFaultElement || this instanceof SOAPEnvelope ||
                this instanceof Detail) {
            throw new SOAPException("EncodingStyle attribute cannot appear in : " + this);
        }
    }
}
项目:wso2-axis2    文件:SOAPEnvelopeTest.java   
public void _testFaults2() throws Exception {
    SOAPEnvelope envelope = getSOAPEnvelope();
    SOAPBody body = envelope.getBody();
    SOAPFault fault = body.addFault();

    assertTrue(body.getFault() != null);

    Detail d1 = fault.addDetail();
    Name name = envelope.createName("GetLastTradePrice", "WOMBAT",
                                    "http://www.wombat.org/trader");
    d1.addDetailEntry(name);

    Detail d2 = fault.getDetail();
    assertTrue(d2 != null);
    Iterator i = d2.getDetailEntries();
    assertTrue(getIteratorCount(i) == 1);
    i = d2.getDetailEntries();
    while (i.hasNext()) {
        DetailEntry de = (DetailEntry)i.next();
        assertEquals(de.getElementName(), name);
    }
}
项目:wso2-axis2    文件:SOAPFactoryTest.java   
@Validated @Test
public void testCreateDetail() {
    try {
        SOAPFactory sf = SOAPFactory.newInstance();
        if (sf == null) {
            fail("SOAPFactory was null");
        }
        Detail d = sf.createDetail();
        if (d == null) {
            fail("Detail was null");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Unexpected Exception " + e);
    }
}
项目:wso2-axis2    文件:SOAPFaultTest.java   
public void _testQuick() throws Exception {
    MessageFactory msgfactory = MessageFactory.newInstance();
    SOAPFactory factory = SOAPFactory.newInstance();
    SOAPMessage outputmsg = msgfactory.createMessage();
    String valueCode = "faultcode";
    String valueString = "faultString";
    SOAPFault fault = outputmsg.getSOAPPart().getEnvelope().getBody().addFault();
    fault.setFaultCode(valueCode);
    fault.setFaultString(valueString);
    Detail detail = fault.addDetail();
    detail.addDetailEntry(factory.createName("Hello"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    if (outputmsg.saveRequired()) {
        outputmsg.saveChanges();
    }
    outputmsg.writeTo(baos);
    String xml = new String(baos.toByteArray());
    assertTrue(xml.indexOf("Hello") != -1);
}
项目:wso2-axis2    文件:SOAPFaultTest.java   
@Validated @Test
public void testHasDetail() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    //MessageFactory fac = MessageFactory.newInstance();

    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();

    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    Detail detail = soapFault.addDetail();
    detail.setAttribute("test", "myvalue");
    soapMessage.saveChanges();
}
项目:wso2-axis2    文件:SAAJDetailTest.java   
@Validated @Test
public void testAddDetailEntry2() throws Exception {
    msg = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
    sp = msg.getSOAPPart();
    envelope = sp.getEnvelope();
    body = envelope.getBody();

    //Add a SOAPFault object to the SOAPBody
    SOAPFault sf = body.addFault();
    //Add a Detail object to the SOAPFault object
    Detail d = sf.addDetail();
    QName name = new QName("http://www.wombat.org/trader",
                           "GetLastTradePrice", "WOMBAT");
    //Add a DetailEntry object to the Detail object
    DetailEntry de = d.addDetailEntry(name);
    //Successfully created DetailEntry object
    assertNotNull(de);
    assertTrue(de instanceof DetailEntry);
}
项目:anythingworks    文件:SoapFaultExceptionTranslator.java   
/**
 * It can either e within an extra tag, or directly.
 */
private Iterator detailChildrenIterator(Detail detail) {
    /*
    sb.append("<ns2:AccessDeniedWebServiceException xmlns:ns2=\"http://exceptionthrower.system.services.v4_0.soap.server.nameapi.org/\">");
    sb.append("<blame>CLIENT</blame>");
    sb.append("<errorCode>2101</errorCode>");
    sb.append("<faultCause>AccessDenied</faultCause>");
     */

    DetailEntry firstDetailEntry = getFirstDetailEntry(detail);
    if (firstDetailEntry!=null) {
        String localName = firstDetailEntry.getElementName().getLocalName();
        if (localName.endsWith("Exception")) {
            //got a subtag
            return firstDetailEntry.getChildElements();
        }
    }
    return detail.getDetailEntries();
}
项目:openjdk-icedtea7    文件:SOAP11Fault.java   
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.saajSoapFactory.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 SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
项目: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);
        }
    }
}
项目:OpenJSharp    文件:SOAPFaultBuilder.java   
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
项目:openjdk-jdk10    文件:SOAPFaultBuilder.java   
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
项目:openjdk9    文件:SOAPFaultBuilder.java   
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
项目:hermes    文件:SOAPResponse.java   
/**
 * Adds a SOAP fault to the SOAP message of this response.
 * 
 * @param cause the exception cause.
 * @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(Throwable cause) throws SOAPException {
    if ((cause instanceof SOAPRequestException)
            && ((SOAPRequestException) cause).isSOAPFault()) {
        SOAPFaultException sfe = ((SOAPRequestException) cause)
                .getSOAPFault();
        SOAPFault fault = addFault(sfe.getFaultCode(), sfe.getFaultActor(),
                sfe.getFaultString());
        if (fault != null && sfe.hasDetailEntries()) {
            Detail detail = fault.addDetail();
            Iterator detailEntries = sfe.getDetailEntryNames();
            while (detailEntries.hasNext()) {
                Name entryName = (Name) detailEntries.next();
                DetailEntry entry = detail.addDetailEntry(entryName);

                Object entryValue = sfe.getDetailEntryValue(entryName);
                if (entryValue instanceof SOAPElement) {
                    entry.addChildElement((SOAPElement) entryValue);
                }
                else {
                    entry.addTextNode(entryValue.toString());
                }
            }
        }
        return fault;
    }
    else {
        return addFault(SOAPFaultException.SOAP_FAULT_SERVER, null, cause
                .toString());
    }
}
项目:hermes    文件:SOAPValidationException.java   
/** 
 * Get SOAP Fault message from the information given.
 * 
 * @return <code>SOAPMessage</code> object containing Fault element.
 */
public SOAPMessage getSOAPMessage() {
    try {
        final MessageFactory mf = MessageFactory.newInstance();
        final SOAPMessage message = (SOAPMessage)mf.createMessage();

        // set default SOAP XML declaration and encoding
        message.setProperty(SOAPMessage.WRITE_XML_DECLARATION, 
                Boolean.toString(EbxmlMessage.WRITE_XML_DECLARATION));
        message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, 
                EbxmlMessage.CHARACTER_SET_ENCODING);

        final SOAPPart part = message.getSOAPPart();
        final SOAPEnvelope envelope = part.getEnvelope();
        final SOAPBody body = envelope.getBody();
        final SOAPFault fault = body.addFault();

        fault.setFaultCode(errorCode);
        fault.setFaultString(errorString);
        if (faultActor != null) {
            fault.setFaultActor(faultActor);
        }
        if (detail != null) {
            Detail d = fault.addDetail();
            Name name = envelope.createName(ELEMENT_ERROR, 
                NAMESPACE_PREFIX_CECID, NAMESPACE_URI_CECID);
            DetailEntry entry = d.addDetailEntry(name);
            entry.addTextNode(detail);
        }

        return message;
    }
    catch (SOAPException e) {
    }

    return null;
}
项目:engerek    文件:MiscSchemaUtil.java   
public static void serializeFaultMessage(Detail detail, FaultMessage faultMessage, PrismContext prismContext, Trace logger) {
       try {
        BeanMarshaller marshaller = ((PrismContextImpl) prismContext).getBeanMarshaller();
        XNode faultMessageXnode = marshaller.marshall(faultMessage.getFaultInfo());         // TODO
           RootXNode xroot = new RootXNode(SchemaConstants.FAULT_MESSAGE_ELEMENT_NAME, faultMessageXnode);
           xroot.setExplicitTypeDeclaration(true);
           QName faultType = prismContext.getSchemaRegistry().determineTypeForClass(faultMessage.getFaultInfo().getClass());
           xroot.setTypeQName(faultType);
        ((PrismContextImpl) prismContext).getParserDom().serializeUnderElement(xroot, SchemaConstants.FAULT_MESSAGE_ELEMENT_NAME, detail);
       } catch (SchemaException e) {
           logger.error("Error serializing fault message (SOAP fault detail): {}", e.getMessage(), e);
       }
}
项目:lookaside_java-1.8.0-openjdk    文件:SOAPFaultBuilder.java   
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
项目:infobip-open-jdk-8    文件:SOAPFaultBuilder.java   
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
项目:jplag    文件:JPlagServerAccessHandler.java   
/**
 * Manually builds up a JPlagException SOAP message and replaces the
 * original one with it
 */
public void replaceByJPlagException(SOAPMessageContext smsg, String desc, String rep) {
    try {
        SOAPMessage msg = smsg.getMessage();
        SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();

        /*
         * Remove old header andy body
         */

        SOAPHeader oldheader = envelope.getHeader();
        if (oldheader != null)
            oldheader.detachNode();
        SOAPBody oldbody = envelope.getBody();
        if (oldbody != null)
            oldbody.detachNode();

        SOAPBody sb = envelope.addBody();
        SOAPFault sf = sb.addFault(envelope.createName("Server", "env", SOAPConstants.URI_NS_SOAP_ENVELOPE),
                "jplagWebService.server.JPlagException");
        Detail detail = sf.addDetail();
        DetailEntry de = detail.addDetailEntry(envelope.createName("JPlagException", "ns0", JPLAG_WEBSERVICE_BASE_URL + "types"));

        SOAPElement e = de.addChildElement("exceptionType");
        e.addTextNode("accessException");

        e = de.addChildElement("description");
        e.addTextNode(desc);

        e = de.addChildElement("repair");
        e.addTextNode(rep);
    } catch (SOAPException x) {
        x.printStackTrace();
    }
}
项目:jax-ws    文件:JAXWSProviderService.java   
private SOAPFault newSOAPFault(String errorMsg) {
try {
    MessageFactory mf = MessageFactory
        .newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);

    SOAPMessage msg = mf.createMessage();

    SOAPFault fault = msg.getSOAPBody().addFault();

    QName faultName = new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE,
        "Client");
    fault.setFaultCode(faultName);
    fault.setFaultString(errorMsg);

    Detail detail = fault.addDetail();

    QName entryName = new QName(
        "http://abhijitsarkar.name/webservices/jaxws/provider/",
        "error", "ns");
    DetailEntry entry = detail.addDetailEntry(entryName);
    entry.addTextNode(errorMsg);

    return fault;
} catch (Exception e) {
    throw new WebServiceException(e.getMessage(), e);
}
   }
项目:switchyard    文件:FaultBeanImpl.java   
@Override
public void OperationA() throws Exception {
       MessageFactory fac = MessageFactory.newInstance();

       //Create a SOAPFault and throw it through SOAPFaultException
       SOAPMessage soapMessage = fac.createMessage();
       SOAPPart soapPart = soapMessage.getSOAPPart();
       SOAPEnvelope envelope = soapPart.getEnvelope();
       SOAPBody body = envelope.getBody();

       //Create a generic SOAPFault object
       SOAPFault soapFault = body.addFault();
       soapFault.setFaultCode("Client");
       soapFault.setFaultString("Generic fault");

       //Add custom fault detail information
       Detail customFaultDetail = soapFault.addDetail();

       Name customFaultElementName = envelope.createName("Fault", "sy", "http://fault.switchyard.org/fault");
       DetailEntry customFaultElement = customFaultDetail.addDetailEntry(customFaultElementName);

       // Add a custom fault code element
       SOAPElement customFaultCodeElement = customFaultElement.addChildElement("FaultCode");
       customFaultCodeElement.addTextNode("CUSTOMFAULTCODE");

       // Add a custom fault message element with qualified name
       SOAPElement customQNamedFaultElement = customFaultElement.addChildElement(envelope.createName("FaultMessage", "sy", "http://fault.switchyard.org/fault"));
       customQNamedFaultElement.addTextNode("Custom fault message");

    SOAPFaultException soapFaultException = new SOAPFaultException(soapFault);

    throw soapFaultException;
}
项目:midpoint    文件:MiscSchemaUtil.java   
public static void serializeFaultMessage(Detail detail, FaultMessage faultMessage, PrismContext prismContext, Trace logger) {
       try {
        BeanMarshaller marshaller = ((PrismContextImpl) prismContext).getBeanMarshaller();
        XNode faultMessageXnode = marshaller.marshall(faultMessage.getFaultInfo());         // TODO
           RootXNode xroot = new RootXNode(SchemaConstants.FAULT_MESSAGE_ELEMENT_NAME, faultMessageXnode);
           xroot.setExplicitTypeDeclaration(true);
           QName faultType = prismContext.getSchemaRegistry().determineTypeForClass(faultMessage.getFaultInfo().getClass());
           xroot.setTypeQName(faultType);
        ((PrismContextImpl) prismContext).getParserDom().serializeUnderElement(xroot, SchemaConstants.FAULT_MESSAGE_ELEMENT_NAME, detail);
       } catch (SchemaException e) {
           logger.error("Error serializing fault message (SOAP fault detail): {}", e.getMessage(), e);
       }
}
项目:OLD-OpenJDK8    文件:SOAPFaultBuilder.java   
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
项目:wso2-axis2    文件:XMLFaultUtils.java   
private static Block[] getDetailBlocks(javax.xml.soap.SOAPFault soapFault)
        throws WebServiceException {
    try {
        Block[] blocks = null;
        Detail detail = soapFault.getDetail();
        if (detail != null) {
            // Get a SAAJ->OM converter
            SAAJConverterFactory converterFactory = (SAAJConverterFactory)FactoryRegistry
                    .getFactory(SAAJConverterFactory.class);
            SAAJConverter converter = converterFactory.getSAAJConverter();

            // Create a block for each element
            OMBlockFactory bf =
                    (OMBlockFactory)FactoryRegistry.getFactory(OMBlockFactory.class);
            ArrayList<Block> list = new ArrayList<Block>();
            Iterator it = detail.getChildElements();
            while (it.hasNext()) {
                DetailEntry de = (DetailEntry)it.next();
                OMElement om = converter.toOM(de);
                Block b = bf.createFrom(om, null, om.getQName());
                list.add(b);
            }
            blocks = new Block[list.size()];
            blocks = list.toArray(blocks);
        }
        return blocks;
    } catch (Exception e) {
        throw ExceptionFactory.makeWebServiceException(e);
    }
}
项目:wso2-axis2    文件:SAAJConverterImpl.java   
/**
 * Create child SOAPElement
 *
 * @param parent SOAPElement
 * @param name   Name
 * @return
 */
protected SOAPElement createElement(SOAPElement parent, QName qName)
        throws SOAPException {
    SOAPElement child;
    if (parent instanceof SOAPEnvelope) {
        if (qName.getNamespaceURI().equals(parent.getNamespaceURI())) {
            if (qName.getLocalPart().equals("Body")) {
                child = ((SOAPEnvelope)parent).addBody();
            } else {
                child = ((SOAPEnvelope)parent).addHeader();
            }
        } else {
            child = parent.addChildElement(qName);
        }
    } else if (parent instanceof SOAPBody) {
        if (qName.getNamespaceURI().equals(parent.getNamespaceURI()) &&
                qName.getLocalPart().equals("Fault")) {
            child = ((SOAPBody)parent).addFault();
        } else {
            child = ((SOAPBody)parent).addBodyElement(qName);
        }
    } else if (parent instanceof SOAPHeader) {
        child = ((SOAPHeader)parent).addHeaderElement(qName);
    } else if (parent instanceof SOAPFault) {
        // This call assumes that the addChildElement implementation
        // is smart enough to add "Detail" or "SOAPFaultElement" objects.
        child = parent.addChildElement(qName);
    } else if (parent instanceof Detail) {
        child = ((Detail)parent).addDetailEntry(qName);
    } else {
        child = parent.addChildElement(qName);
    }

    return child;
}
项目:wso2-axis2    文件:SAAJDetailTest.java   
@Validated @Test
public void testAddDetailEntry() throws Exception {
    //Add a SOAPFault object to the SOAPBody
    SOAPFault sf = body.addFault();
    //Add a Detail object to the SOAPFault object
    Detail d = sf.addDetail();
    QName name = new QName("http://www.wombat.org/trader",
                           "GetLastTradePrice", "WOMBAT");
    //Add a DetailEntry object to the Detail object
    DetailEntry de = d.addDetailEntry(name);
    assertNotNull(de);
    assertTrue(de instanceof DetailEntry);
}