當前位置: 首頁>>代碼示例>>Java>>正文


Java SOAPFault.addDetail方法代碼示例

本文整理匯總了Java中javax.xml.soap.SOAPFault.addDetail方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPFault.addDetail方法的具體用法?Java SOAPFault.addDetail怎麽用?Java SOAPFault.addDetail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.soap.SOAPFault的用法示例。


在下文中一共展示了SOAPFault.addDetail方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _testQuick

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
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);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:20,代碼來源:SOAPFaultTest.java

示例2: getProtocolException

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:17,代碼來源:SOAP11Fault.java

示例3: invoke

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@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);
        }
    }
}
 
開發者ID:Pardus-Engerek,項目名稱:engerek,代碼行數:24,代碼來源:ModelWebServiceRaw.java

示例4: invoke

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
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);
   }
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:17,代碼來源:ProviderImpl.java

示例5: throwSoapFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
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);

  }
 
開發者ID:bertique,項目名稱:SonosNPROneServer,代碼行數:22,代碼來源:SonosService.java

示例6: testDetails

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Test
public void testDetails() throws Exception {
    MessageFactory mf = MessageFactory.newInstance();
    SOAPMessage smsg =
            mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
    SOAPBody body = smsg.getSOAPBody();
    //smsg.writeTo(System.out);
    SOAPFault fault = body.getFault();
    fault.addDetail();
    javax.xml.soap.Detail d = fault.getDetail();
    Iterator i = d.getDetailEntries();
    while (i.hasNext()) {
        DetailEntry entry = (DetailEntry)i.next();
        String name = entry.getElementName().getLocalName();
        if ("tickerSymbol".equals(name)) {
            assertEquals("the value of the tickerSymbol element didn't match",
                         "MACR", entry.getValue());
        } else if ("exceptionName".equals(name)) {
            assertEquals("the value of the exceptionName element didn't match",
                         "test.wsdl.faults.InvalidTickerFaultMessage", entry.getValue());
        } else {
            assertTrue("Expecting details element name of 'tickerSymbol' or " +
                    "'expceptionName' - I found :" + name, false);
        }
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:27,代碼來源:SOAPFaultDetailTest.java

示例7: _testFaults2

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:23,代碼來源:SOAPEnvelopeTest.java

示例8: testHasDetail

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@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();
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:17,代碼來源:SOAPFaultTest.java

示例9: testAddDetailEntry2

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@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);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:20,代碼來源:SAAJDetailTest.java

示例10: getProtocolException

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:alexkasko,項目名稱:openjdk-icedtea7,代碼行數:17,代碼來源:SOAP11Fault.java

示例11: addFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
/**
 * 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());
    }
}
 
開發者ID:cecid,項目名稱:hermes,代碼行數:40,代碼來源:SOAPResponse.java

示例12: getSOAPMessage

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
/** 
 * 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;
}
 
開發者ID:cecid,項目名稱:hermes,代碼行數:42,代碼來源:SOAPValidationException.java

示例13: replaceByJPlagException

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
/**
 * 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();
	}
}
 
開發者ID:jplag,項目名稱:jplag,代碼行數:39,代碼來源:JPlagServerAccessHandler.java

示例14: newSOAPFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
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);
}
   }
 
開發者ID:asarkar,項目名稱:jax-ws,代碼行數:28,代碼來源:JAXWSProviderService.java

示例15: OperationA

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@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;
}
 
開發者ID:jboss-switchyard,項目名稱:switchyard,代碼行數:34,代碼來源:FaultBeanImpl.java


注:本文中的javax.xml.soap.SOAPFault.addDetail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。