本文整理汇总了Java中javax.xml.soap.DetailEntry类的典型用法代码示例。如果您正苦于以下问题:Java DetailEntry类的具体用法?Java DetailEntry怎么用?Java DetailEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DetailEntry类属于javax.xml.soap包,在下文中一共展示了DetailEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDetails
import javax.xml.soap.DetailEntry; //导入依赖的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);
}
}
}
示例2: _testFaults2
import javax.xml.soap.DetailEntry; //导入依赖的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);
}
}
示例3: testAddDetailEntry2
import javax.xml.soap.DetailEntry; //导入依赖的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);
}
示例4: detailChildrenIterator
import javax.xml.soap.DetailEntry; //导入依赖的package包/类
/**
* 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();
}
示例5: getFirstDetailEntryName
import javax.xml.soap.DetailEntry; //导入依赖的package包/类
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;
}
示例6: addFault
import javax.xml.soap.DetailEntry; //导入依赖的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());
}
}
示例7: getSOAPMessage
import javax.xml.soap.DetailEntry; //导入依赖的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;
}
示例8: replaceByJPlagException
import javax.xml.soap.DetailEntry; //导入依赖的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();
}
}
示例9: newSOAPFault
import javax.xml.soap.DetailEntry; //导入依赖的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);
}
}
示例10: OperationA
import javax.xml.soap.DetailEntry; //导入依赖的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;
}
示例11: getDetailBlocks
import javax.xml.soap.DetailEntry; //导入依赖的package包/类
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);
}
}
示例12: testAddDetailEntry
import javax.xml.soap.DetailEntry; //导入依赖的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);
}
示例13: getFirstDetailEntry
import javax.xml.soap.DetailEntry; //导入依赖的package包/类
@Nullable
private DetailEntry getFirstDetailEntry(@NotNull Detail detail) {
Iterator detailEntries = detail.getDetailEntries();
while (detailEntries.hasNext()) {
Object next = detailEntries.next();
if (next instanceof DetailEntry) {
return (DetailEntry)next;
}
}
return null;
}
示例14: createDetailEntry
import javax.xml.soap.DetailEntry; //导入依赖的package包/类
protected DetailEntry createDetailEntry(Name name) {
return new DetailEntry1_1Impl(
(SOAPDocumentImpl) getOwnerDocument(),
name);
}
示例15: createDetailEntry
import javax.xml.soap.DetailEntry; //导入依赖的package包/类
@Override
protected DetailEntry createDetailEntry(Name name) {
return new DetailEntry1_1Impl(
(SOAPDocumentImpl) getOwnerDocument(),
name);
}