本文整理汇总了Java中org.apache.axis2.util.MessageContextBuilder.createFaultMessageContext方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContextBuilder.createFaultMessageContext方法的具体用法?Java MessageContextBuilder.createFaultMessageContext怎么用?Java MessageContextBuilder.createFaultMessageContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.util.MessageContextBuilder
的用法示例。
在下文中一共展示了MessageContextBuilder.createFaultMessageContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFaultReason
import org.apache.axis2.util.MessageContextBuilder; //导入方法依赖的package包/类
public void testFaultReason() throws Exception {
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
OMElement response = soapFactory.createOMElement(new QName("testNs",
"test"));
String faultReason = "myFaultReason";
AxisFault fault = new AxisFault(new QName("myQname"), faultReason,
"myFaultNode", "myFaultRole", response);
ConfigurationContext cc = ConfigurationContextFactory
.createDefaultConfigurationContext();
MessageContext ctx = cc.createMessageContext();
SOAPFactory fac = OMAbstractFactory.getSOAP12Factory();
ctx.setEnvelope(fac.getDefaultEnvelope());
MessageContext faultCtx = MessageContextBuilder
.createFaultMessageContext(ctx, fault);
assertEquals(faultReason, Utils.getInboundFaultFromMessageContext(
faultCtx).getReason());
}
示例2: createFaultMessageContext
import org.apache.axis2.util.MessageContextBuilder; //导入方法依赖的package包/类
/**
* Given a request MessageContext, create a new MessageContext for a fault response.
*
* @param mc
* @return
*/
public static MessageContext createFaultMessageContext(MessageContext mc) {
try {
org.apache.axis2.context.MessageContext faultMC =
MessageContextBuilder.createFaultMessageContext(mc.getAxisMessageContext(),
null);
MessageContext jaxwsFaultMC = new MessageContext(faultMC);
jaxwsFaultMC.setOutbound(true);
jaxwsFaultMC.setServer(true);
jaxwsFaultMC.setMEPContext(mc.getMEPContext());
jaxwsFaultMC.setEndpointDescription(mc.getEndpointDescription());
jaxwsFaultMC.setOperationDescription(mc.getOperationDescription());
return jaxwsFaultMC;
}
catch (AxisFault e) {
throw ExceptionFactory.makeWebServiceException(e);
}
}
示例3: run
import org.apache.axis2.util.MessageContextBuilder; //导入方法依赖的package包/类
public void run() {
try {
ThreadContextDescriptor tc = setThreadContext(messageCtx);
try {
invokeBusinessLogic(messageCtx);
} finally {
restoreThreadContext(tc);
}
} catch (AxisFault e) {
// If we're IN-ONLY, swallow this. Otherwise, send it.
if (messageCtx.getAxisOperation() instanceof InOnlyAxisOperation) {
log.debug(e.getMessage(), e);
} else {
try {
MessageContext faultContext =
MessageContextBuilder.createFaultMessageContext(messageCtx, e);
AxisEngine.sendFault(faultContext);
} catch (AxisFault axisFault) {
log.error(e.getMessage(), e);
}
log.error(e.getMessage(), e);
}
}
}
示例4: sendFault
import org.apache.axis2.util.MessageContextBuilder; //导入方法依赖的package包/类
private void sendFault(MessageContext msgContext, Exception fault) {
log.error("Error while processing TCP request through the Axis2 engine", fault);
try {
if (msgContext != null) {
msgContext.setProperty(MessageContext.TRANSPORT_OUT, socket.getOutputStream());
MessageContext faultContext =
MessageContextBuilder.createFaultMessageContext(msgContext, fault);
AxisEngine.sendFault(faultContext);
}
} catch (Exception e) {
log.error("Error while sending the fault response", e);
}
}
示例5: run
import org.apache.axis2.util.MessageContextBuilder; //导入方法依赖的package包/类
public void run() {
MessageContext msgCtx = null;
try {
msgCtx = createMessageContext(packet);
Object obj = msgCtx.getProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE);
if(obj != null && ((Boolean)obj).booleanValue()){
if(msgCtx.isProcessingFault() && msgCtx.isServerSide()){
AxisEngine.sendFault(msgCtx);
}else{
AxisEngine.receive(msgCtx);
}
}else{
//Send a text reply message to command received from chat client
XMPPSender.processChatMessage(msgCtx);
}
} catch (AxisFault e) {
log.error("Error occurred while sending message"+e);
if (msgCtx != null && msgCtx.isServerSide()) {
MessageContext faultContext;
try {
faultContext = MessageContextBuilder.createFaultMessageContext(msgCtx, e);
AxisEngine.sendFault(faultContext);
} catch (AxisFault e1) {
log.error("Error occurred while creating SOAPFault message"+e1);
}
}
}
}
示例6: testFaultSerialization
import org.apache.axis2.util.MessageContextBuilder; //导入方法依赖的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);
}
示例7: handleFault
import org.apache.axis2.util.MessageContextBuilder; //导入方法依赖的package包/类
protected void handleFault(MessageContext msgContext, OutputStream out, AxisFault e)
throws AxisFault {
msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
MessageContext faultContext =
MessageContextBuilder.createFaultMessageContext(msgContext, e);
// SOAP 1.2 specification mentions that we should send HTTP code 400 in a fault if the
// fault code Sender
HttpServletResponse response =
(HttpServletResponse) msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
if (response != null) {
//TODO : Check for SOAP 1.2!
SOAPFaultCode code = faultContext.getEnvelope().getBody().getFault().getCode();
OMElement valueElement = null;
if (code != null) {
valueElement = code.getFirstChildWithName(new QName(
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
SOAP12Constants.SOAP_FAULT_VALUE_LOCAL_NAME));
}
if (valueElement != null) {
if (SOAP12Constants.FAULT_CODE_SENDER.equals(valueElement.getTextAsQName().getLocalPart())
&& !msgContext.isDoingREST()) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
}
}
AxisEngine.sendFault(faultContext);
}
示例8: createFaultMessageContext
import org.apache.axis2.util.MessageContextBuilder; //导入方法依赖的package包/类
/**
* This method is called to handle any error that occurs at inflow or outflow. But if the
* method is called twice, it implies that sending the error handling has failed, in which case
* the method logs the error and exists.
*
* @deprecated (post 1.1 branch)
*/
public static MessageContext createFaultMessageContext(MessageContext processingContext, Throwable e)
throws AxisFault {
return MessageContextBuilder.createFaultMessageContext(processingContext, e);
}