当前位置: 首页>>代码示例>>Java>>正文


Java Detail.addDetailEntry方法代码示例

本文整理汇总了Java中javax.xml.soap.Detail.addDetailEntry方法的典型用法代码示例。如果您正苦于以下问题:Java Detail.addDetailEntry方法的具体用法?Java Detail.addDetailEntry怎么用?Java Detail.addDetailEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.soap.Detail的用法示例。


在下文中一共展示了Detail.addDetailEntry方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _testQuick

import javax.xml.soap.Detail; //导入方法依赖的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: _testFaults2

import javax.xml.soap.Detail; //导入方法依赖的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

示例3: testAddDetailEntry2

import javax.xml.soap.Detail; //导入方法依赖的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

示例4: addFault

import javax.xml.soap.Detail; //导入方法依赖的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

示例5: getSOAPMessage

import javax.xml.soap.Detail; //导入方法依赖的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

示例6: replaceByJPlagException

import javax.xml.soap.Detail; //导入方法依赖的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

示例7: newSOAPFault

import javax.xml.soap.Detail; //导入方法依赖的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

示例8: OperationA

import javax.xml.soap.Detail; //导入方法依赖的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

示例9: testAddDetailEntry

import javax.xml.soap.Detail; //导入方法依赖的package包/类
@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);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:14,代码来源:SAAJDetailTest.java

示例10: testFaults

import javax.xml.soap.Detail; //导入方法依赖的package包/类
@Validated @Test
public void testFaults() throws Exception {
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPFactory soapFactory = SOAPFactory.newInstance();
    SOAPMessage message = messageFactory.createMessage();
    SOAPBody body = message.getSOAPBody();
    SOAPFault fault = body.addFault();

    Name faultName =
            soapFactory.createName("Client", "",
                                   SOAPConstants.URI_NS_SOAP_ENVELOPE);
    fault.setFaultCode(faultName);

    fault.setFaultString("Message does not have necessary info");
    fault.setFaultActor("http://gizmos.com/order");

    Detail detail = fault.addDetail();

    Name entryName =
            soapFactory.createName("order", "PO",
                                   "http://gizmos.com/orders/");
    DetailEntry entry = detail.addDetailEntry(entryName);
    entry.addTextNode("Quantity element does not have a value");

    Name entryName2 =
            soapFactory.createName("confirmation", "PO",
                                   "http://gizmos.com/confirm");
    DetailEntry entry2 = detail.addDetailEntry(entryName2);
    entry2.addTextNode("Incomplete address: " + "no zip code");

    message.saveChanges();
    //message.writeTo(System.out);

    // Now retrieve the SOAPFault object and
    // its contents, after checking to see that
    // there is one
    if (body.hasFault()) {
        SOAPFault newFault = body.getFault();

        // Get the qualified name of the fault code
        assertNotNull(newFault.getFaultCodeAsName());
        assertNotNull(newFault.getFaultString());
        assertNotNull(newFault.getFaultActor());
        Detail newDetail = newFault.getDetail();

        if (newDetail != null) {
            Iterator entries = newDetail.getDetailEntries();

            while (entries.hasNext()) {
                DetailEntry newEntry = (DetailEntry)entries.next();
                String value = newEntry.getValue();
                assertNotNull(value);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:57,代码来源:SOAPFaultTest.java


注:本文中的javax.xml.soap.Detail.addDetailEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。