本文整理汇总了Java中org.apache.axiom.soap.SOAPFaultDetail类的典型用法代码示例。如果您正苦于以下问题:Java SOAPFaultDetail类的具体用法?Java SOAPFaultDetail怎么用?Java SOAPFaultDetail使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SOAPFaultDetail类属于org.apache.axiom.soap包,在下文中一共展示了SOAPFaultDetail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSOAP11FaultDetailAsElement
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "Creating SOAP1.1 fault details as Element")
public void testSOAP11FaultDetailAsElement() throws AxisFault {
try {
axis2Client.sendSimpleStockQuoteRequest(
getMainSequenceURL(),
null,
"WSO2");
fail("This query must throw an exception.");
} catch (AxisFault expected) {
log.info("Fault Message : " + expected.getMessage());
assertEquals(expected.getReason(), "Soap11FaultDetailAsElementTestCase", "Fault Reason Mismatched");
assertEquals(expected.getFaultCode().getPrefix(), "soap11Env", "Fault code prefix mismatched");
SOAPFaultDetail detailElm = expected.getFaultDetailElement();
OMElement statusOME = detailElm.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "StatusCode", "axis2ns1"));
assertNotNull(statusOME, "Fault detail element StatusCode null");
assertEquals(statusOME.getText(), "1000", "Fault detail StatusCode mismatched");
OMElement messageOME = detailElm.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "message", "axis2ns1"));
assertNotNull(messageOME, "Fault detail element message null");
assertEquals(messageOME.getText(), "fault details by automation", "Fault detail message mismatched");
}
}
示例2: testSOAP12FaultDetailAsElement
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "Creating SOAP1.2 fault details as Element")
public void testSOAP12FaultDetailAsElement() throws AxisFault {
try {
axis2Client.sendSimpleStockQuoteSoap12(
getMainSequenceURL(),
"http://localhost:9010/services/NonExistingService",
"WSO2");
fail("This query must throw an exception.");
} catch (AxisFault expected) {
log.info("Fault Message : " + expected.getMessage());
assertEquals(expected.getReason(), "Soap12FaultDetailAsElementTestCase", "Fault Reason Mismatched");
assertEquals(expected.getFaultCode().getLocalPart(), "VersionMismatch", "Fault code value mismatched");
assertEquals(expected.getFaultCode().getPrefix(), "soap12Env", "Fault code prefix mismatched");
SOAPFaultDetail detailElm = expected.getFaultDetailElement();
OMElement statusOME = detailElm.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "StatusCode", "axis2ns1"));
assertNotNull(statusOME, "Fault detail element StatusCode null");
assertEquals(statusOME.getText(), "1000", "Fault detail StatusCode mismatched");
OMElement messageOME = detailElm.getFirstChildWithName(new QName("http://ws.apache.org/ns/synapse", "message", "axis2ns1"));
assertNotNull(messageOME, "Fault detail element message null");
assertEquals(messageOME.getText(), "fault details by automation", "Fault detail message mismatched");
}
}
示例3: createSoapFault
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
/**
* Crete SOAP Fault from fault information returned from ODE.
*
* @param bpelMessageContext DTO containing information on current messageflow.
* @param odeMessageContext ODE MyRoleMessageExchange containing information on current process
* invocation.
* @return SOAPFault instance
* @throws AxisFault in case of a error while creating SOAP Fault.
*/
public static SOAPFault createSoapFault(final BPELMessageContext bpelMessageContext,
final MessageExchange odeMessageContext)
throws AxisFault {
SOAPFactory soapFactory = bpelMessageContext.getSoapFactoryForCurrentMessageFlow();
OMElement detail = buildSoapDetail(bpelMessageContext, odeMessageContext);
SOAPFault fault = soapFactory.createSOAPFault();
SOAPFaultCode code = soapFactory.createSOAPFaultCode(fault);
code.setText(new QName(Namespaces.SOAP_ENV_NS, "Server"));
SOAPFaultReason reason = soapFactory.createSOAPFaultReason(fault);
reason.setText(odeMessageContext.getFault());
SOAPFaultDetail soapDetail = soapFactory.createSOAPFaultDetail(fault);
if (detail != null) {
soapDetail.addDetailEntry(detail);
}
return fault;
}
示例4: parseSoapFault
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
public static Fault parseSoapFault(Element odeMsgEl, SOAPEnvelope envelope, Operation operation)
throws AxisFault {
SOAPFault flt = envelope.getBody().getFault();
SOAPFaultDetail detail = flt.getDetail();
Fault fdef = inferFault(operation, flt);
if (fdef == null) {
return null;
}
Part pdef = (Part) fdef.getMessage().getParts().values().iterator().next();
Element partel = odeMsgEl.getOwnerDocument().createElementNS(null, pdef.getName());
odeMsgEl.appendChild(partel);
if (detail.getFirstChildWithName(pdef.getElementName()) != null) {
partel.appendChild(odeMsgEl.getOwnerDocument().importNode(
OMUtils.toDOM(detail.getFirstChildWithName(pdef.getElementName())), true));
} else {
partel.appendChild(odeMsgEl.getOwnerDocument().importNode(OMUtils.toDOM(detail), true));
}
return fdef;
}
示例5: getDetailBlocks
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
private static Block[] getDetailBlocks(SOAPFault soapFault) throws WebServiceException {
try {
Block[] blocks = null;
SOAPFaultDetail detail = soapFault.getDetail();
if (detail != null) {
// 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()) {
OMElement om = (OMElement) it.next();
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);
}
}
示例6: getXMLFault
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
public XMLFault getXMLFault() throws WebServiceException {
if (!isFault()) {
return null;
}
// Advance through all of the detail blocks
int numDetailBlocks = getNumDetailBlocks();
Block[] blocks = null;
if (numDetailBlocks > 0) {
blocks = new Block[numDetailBlocks];
SOAPFaultDetail detail = root.getBody().getFault().getDetail();
for (int i = 0; i < numDetailBlocks; i++) {
OMElement om = this._getChildOMElement(detail, i);
blocks[i] = this._getBlockFromOMElement(om, null, obf, false);
}
}
XMLFault xmlFault = XMLFaultUtils.createXMLFault(root.getBody().getFault(), blocks);
return xmlFault;
}
示例7: addDetail
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
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;
}
示例8: testGenerateFaults1
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
@Test(groups = "wso2.esb",
description = "Using script mediator to generate faults. Test 1.")
public void testGenerateFaults1() throws XMLStreamException {
try {
axis2Client.sendSimpleStockQuoteRequest(
getProxyServiceURLHttp("scriptMediatorInFaultSequenceTestProxy"), null,
"MSFT");
Assert.fail("Request must throw a AxisFault");
} catch (AxisFault e) {
SOAPFaultDetail faultDetail = e.getFaultDetailElement();
assertNotNull(faultDetail, "Fault response message null");
OMElement firstElemnt = faultDetail.getFirstElement();
OMElement errorCode = firstElemnt.getFirstChildWithName(new QName("ErrorCode"));
OMElement errorText = firstElemnt.getFirstChildWithName(new QName("ErrorText"));
assertEquals(faultDetail.getFirstElement().getLocalName(), "AppErrorCode",
"Fault detail element");
assertEquals(errorCode.getText(), "8719",
"Fault detail element");
assertEquals(errorText.getText(), "Issue has",
"Fault detail element");
}
}
示例9: testGenerateFaults2
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
@Test(groups = "wso2.esb",
description = "Using script mediator to generate faults.Test 2. "
)
public void testGenerateFaults2() throws XMLStreamException {
try {
axis2Client.sendSimpleStockQuoteRequest(
getProxyServiceURLHttp("scriptMediatorInFaultSequenceTestProxy"), null,
"SUN");
Assert.fail("Request must throw a AxisFault");
} catch (AxisFault e) {
SOAPFaultDetail faultDetail = e.getFaultDetailElement();
assertNotNull(faultDetail, "Fault response message null");
OMElement firstElemnt = faultDetail.getFirstElement();
OMElement errorCode = firstElemnt.getFirstChildWithName(new QName("ErrorCode"));
OMElement errorText = firstElemnt.getFirstChildWithName(new QName("ErrorText"));
assertEquals(faultDetail.getFirstElement().getLocalName(), "AppErrorCode",
"Fault detail element");
assertEquals(errorCode.getText(), "8719",
"Fault detail element");
assertEquals(errorText.getText(), "Issue has",
"Fault detail element");
}
}
示例10: testFaultSerialization
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
public void testFaultSerialization() throws Exception {
final String REASON = "ReasonValue";
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode();
SOAPFaultValue soapFaultValue = soapFactory
.createSOAPFaultValue(soapFaultCode);
soapFaultValue.setText(new QName(
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, "Sender"));
SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason();
SOAPFaultText soapFaultText = soapFactory
.createSOAPFaultText(soapFaultReason);
soapFaultText.setText(REASON);
SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail();
QName qName = new QName("http://mycompany.com", "FaultException", "ex");
OMElement exception = soapFactory.createOMElement(qName,
soapFaultDetail);
exception.setText("Detail text");
AxisFault fault = new AxisFault(soapFaultCode, soapFaultReason, null,
null, soapFaultDetail);
ConfigurationContext cc = ConfigurationContextFactory
.createDefaultConfigurationContext();
MessageContext ctx = cc.createMessageContext();
SOAPFactory fac = OMAbstractFactory.getSOAP12Factory();
ctx.setEnvelope(fac.getDefaultEnvelope());
MessageContext faultCtx = MessageContextBuilder
.createFaultMessageContext(ctx, fault);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
TransportUtils.writeMessage(faultCtx, bos);
String result = new String(bos.toByteArray());
// For right now, just making sure we have a test for AXIS2-2752
// Confirm reason was correctly processed
assertTrue("Incorrect or missing reason!", result.indexOf(REASON) > -1);
}
示例11: invoke
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
// this handler will be used to check the fault handling of Axis2.
// this will create some dummy faults and send
SOAPFactory soapFac = msgContext.isSOAP11() ? OMAbstractFactory.getSOAP11Factory() :
OMAbstractFactory.getSOAP12Factory();
// I have a sudden fake error ;)
OMElement firstElement = msgContext.getEnvelope().getBody().getFirstElement();
OMElement detailEntry = soapFac.createOMElement("MoreInfo", null);
detailEntry.setText(DETAIL_MORE_INFO);
if (ERR_HANDLING_WITH_MSG_CTXT.equals(firstElement.getLocalName())) {
SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
soapFaultCode.declareNamespace("http://someuri.org", "m");
if (msgContext.isSOAP11()) {
soapFaultCode.setText(M_FAULT_EXCEPTION);
} else {
SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
soapFaultValue.setText(M_FAULT_EXCEPTION);
}
SOAPFaultReason soapFaultReason = soapFac.createSOAPFaultReason();
if (msgContext.isSOAP11()) {
soapFaultReason.setText(FAULT_REASON);
} else {
SOAPFaultText soapFaultText = soapFac.createSOAPFaultText();
soapFaultText.setLang("en");
soapFaultText.setText(FAULT_REASON);
soapFaultReason.addSOAPText(soapFaultText);
}
SOAPFaultDetail faultDetail = soapFac.createSOAPFaultDetail();
faultDetail.addDetailEntry(detailEntry);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME, soapFaultReason);
msgContext.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, faultDetail);
throw new AxisFault("A dummy exception has occurred");
} else if (ERR_HANDLING_WITH_AXIS_FAULT.equals(firstElement.getLocalName())) {
throw new AxisFault(new QName(M_FAULT_EXCEPTION), FAULT_REASON, null, null,
detailEntry);
}
return InvocationResponse.CONTINUE;
}
示例12: initializeValues
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
private void initializeValues(SOAPFaultCode soapFaultCode,
SOAPFaultReason soapFaultReason,
SOAPFaultNode soapFaultNode,
SOAPFaultRole soapFaultRole,
SOAPFaultDetail soapFaultDetail) {
this.soapFaultCode = soapFaultCode;
this.soapFaultReason = soapFaultReason;
this.soapFaultNode = soapFaultNode;
this.soapFaultRole = soapFaultRole;
this.soapFaultDetail = soapFaultDetail;
if (soapFaultDetail != null) {
// OMElement exceptionElement = soapFaultDetail.getFirstChildWithName(
// new QName(SOAPConstants.SOAP_FAULT_DETAIL_EXCEPTION_ENTRY));
// if (exceptionElement != null && exceptionElement.getText() != null) {
// cause = new Exception(exceptionElement.getText());
// }
// TODO - Wha? Details can have multiple elements, why take the first child here?
// TODO - Review the API for details
// setting the first child element of the fault detail as this.detail
this.detail = soapFaultDetail.getFirstElement();
}
if (soapFaultReason != null) {
message = soapFaultReason.getText();
}
if (soapFaultCode != null) {
// This works the same regardless of SOAP version
faultCode = soapFaultCode.getTextAsQName();
SOAPFaultSubCode subCode = soapFaultCode.getSubCode();
if (subCode != null) {
faultSubCodes = new ArrayList();
while (subCode != null) {
faultSubCodes.add(subCode.getValue().getTextAsQName());
subCode = subCode.getSubCode();
}
}
}
}
示例13: getBytes
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
/**
* Get the bytes for this message
* @param messageContext
* @param format
* @param preserve (indicates if the OM should be preserved or consumed)
* @return
* @throws AxisFault
*/
public byte[] getBytes(MessageContext messageContext,
OMOutputFormat format,
boolean preserve) throws AxisFault {
if (log.isDebugEnabled()) {
log.debug("start getBytes()");
log.debug(" fault flow=" +
(messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW));
}
try {
OMElement omElement;
// Find the correct element to serialize. Normally it is the first element
// in the body. But if this is a fault, use the detail entry element or the
// fault reason.
if (messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW) {
SOAPFault fault = messageContext.getEnvelope().getBody().getFault();
SOAPFaultDetail soapFaultDetail = fault.getDetail();
omElement = soapFaultDetail.getFirstElement();
if (omElement == null) {
omElement = fault.getReason();
}
} else {
// Normal case: The xml payload is the first element in the body.
omElement = messageContext.getEnvelope().getBody().getFirstElement();
}
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
if (omElement != null) {
try {
if (preserve) {
omElement.serialize(bytesOut, format);
} else {
omElement.serializeAndConsume(bytesOut, format);
}
} catch (XMLStreamException e) {
throw AxisFault.makeFault(e);
}
return bytesOut.toByteArray();
}
return new byte[0];
} finally {
if (log.isDebugEnabled()) {
log.debug("end getBytes()");
}
}
}
示例14: DetailImpl
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
/** @param element */
public DetailImpl(SOAPFaultDetail element) {
super((ElementImpl)element);
// faultDetail = element;
}
示例15: AxisFault
import org.apache.axiom.soap.SOAPFaultDetail; //导入依赖的package包/类
/**
* This is just a convenience method for the user. If you set these, do not use other methods
* in this class to get and set things.
* Any of the parameters can be null
*
* @param soapFaultCode the fault code
* @param soapFaultReason the fault reason
* @param soapFaultNode the SOAPFaultNode representing the source node for this fault
* @param soapFaultRole the SOAPFaultRole representing the source role for this fault
* @param soapFaultDetail the SOAPFaultDetail containing any application-specific info
*/
public AxisFault(SOAPFaultCode soapFaultCode, SOAPFaultReason soapFaultReason,
SOAPFaultNode soapFaultNode, SOAPFaultRole soapFaultRole,
SOAPFaultDetail soapFaultDetail) {
initializeValues(soapFaultCode, soapFaultReason, soapFaultNode, soapFaultRole,
soapFaultDetail);
}