本文整理汇总了Java中org.apache.axis2.util.MessageContextBuilder类的典型用法代码示例。如果您正苦于以下问题:Java MessageContextBuilder类的具体用法?Java MessageContextBuilder怎么用?Java MessageContextBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessageContextBuilder类属于org.apache.axis2.util包,在下文中一共展示了MessageContextBuilder类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createResponseMessageContext
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
/**
* Creates the {@link MessageContext} for the response to message currently being processed.
*
* @param reqContext The MessageContext of the received message
* @return The MessageContext for the response message
*/
public static MessageContext createResponseMessageContext(final MessageContext reqContext) {
try {
MessageContext resCtx = null;
// First try to get the context for the response from the OperationContext
final OperationContext opContext = reqContext.getOperationContext();
if (opContext != null) {
resCtx = opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
}
// If that fails, construct a new context
if (resCtx == null) {
resCtx = MessageContextBuilder.createOutMessageContext(reqContext);
resCtx.getOperationContext().addMessageContext(resCtx);
}
return resCtx;
} catch (final AxisFault af) {
// Somewhere the construction of the new MessageContext failed
return null;
}
}
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:30,代码来源:Axis2Utils.java
示例2: 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());
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:20,代码来源:FaultSerializationTest.java
示例3: createResponseMessageContext
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
/**
* Given a request MessageContext, create a new MessageContext from there with the necessary
* information to make sure the new MessageContext is related to the existing one.
*
* @param mc - the MessageContext to use as the source
* @return
*/
public static MessageContext createResponseMessageContext(MessageContext mc) {
try {
org.apache.axis2.context.MessageContext sourceAxisMC = mc.getAxisMessageContext();
// There are a number of things that need to be copied over at the
// Axis2 level.
org.apache.axis2.context.MessageContext newAxisMC =
MessageContextBuilder.createOutMessageContext(sourceAxisMC);
MessageContext newMC = new MessageContext(newAxisMC);
newMC.setOutbound(true);
newMC.setServer(true);
newMC.setMEPContext(mc.getMEPContext());
newMC.setEndpointDescription(mc.getEndpointDescription());
newMC.setOperationDescription(mc.getOperationDescription());
return newMC;
} catch (AxisFault e) {
throw ExceptionFactory.makeWebServiceException(e);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:28,代码来源:MessageContextUtils.java
示例4: 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);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:MessageContextUtils.java
示例5: 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);
}
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:26,代码来源:AbstractMessageReceiver.java
示例6: getAbstractResponseMessageContext
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
public MessageContext getAbstractResponseMessageContext(MessageContext requestMessageContext) throws AxisFault {
MessageContext outMessageCtx = MessageContextBuilder.createOutMessageContext(requestMessageContext);
SOAPFactory factory = getSOAPFactory(requestMessageContext);
AxisOperation operation = requestMessageContext.getOperationContext().getAxisOperation();
AxisService service = requestMessageContext.getAxisService();
OMElement bodyContent;
AxisMessage outMessage = operation.getMessage(OperationsConstants.OUT);
bodyContent = factory.createOMElement(outMessage.getName(),
factory.createOMNamespace(namespace,
service.getSchemaTargetNamespacePrefix()));
try {
setPayload(bodyContent);
} catch (XMLStreamException e) {
String msg = "Error in adding the payload to the response message";
log.error(msg);
throw new AxisFault(msg, e);
}
SOAPEnvelope soapEnvelope = factory.getDefaultEnvelope();
soapEnvelope.getBody().addChild(bodyContent);
outMessageCtx.setEnvelope(soapEnvelope);
return outMessageCtx;
}
开发者ID:wso2,项目名称:carbon-governance,代码行数:27,代码来源:AbstractOperation.java
示例7: createResponseContext
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
/**
* Creates a new {@see MessageContext} for the response.
*
* @param msgContext The current, i.e. in flow, message context
* @return The new message context for the outgoing flow
* @throws AxisFault When an error occurs during the creation of the response
* message context
*/
protected MessageContext createResponseContext(final MessageContext msgContext) throws AxisFault {
final MessageContext outMsgContext = MessageContextBuilder.createOutMessageContext(msgContext);
outMsgContext.getOperationContext().addMessageContext(outMsgContext);
replicateState(msgContext);
return outMsgContext;
}
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:17,代码来源:CheckForResponse.java
示例8: setOutMessageContextToBPELMessageContext
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
private static void setOutMessageContextToBPELMessageContext(
final BPELMessageContext bpelMessageContext)
throws AxisFault {
MessageContext outMessageContext = MessageContextBuilder
.createOutMessageContext(bpelMessageContext.getInMessageContext());
outMessageContext.getOperationContext().addMessageContext(outMessageContext);
bpelMessageContext.setOutMessageContext(outMessageContext);
}
开发者ID:wso2,项目名称:carbon-business-process,代码行数:9,代码来源:BPELMessageContextFactory.java
示例9: dispatchResponse
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
/**
* Dispatch the message to the target endpoint
*
* @param soapEnvelope Soap Enevlop with message
* @param responseAction WSE action for the response
* @param mc Message Context
* @param isFault Whether a Fault message must be sent
* @throws AxisFault Thrown by the axis2 engine.
*/
private void dispatchResponse(SOAPEnvelope soapEnvelope, String responseAction,
MessageContext mc, boolean isFault) throws AxisFault {
MessageContext rmc = MessageContextBuilder.createOutMessageContext(mc);
rmc.getOperationContext().addMessageContext(rmc);
replicateState(mc);
rmc.setEnvelope(soapEnvelope);
rmc.setWSAAction(responseAction);
rmc.setSoapAction(responseAction);
if (isFault) {
AxisEngine.sendFault(rmc);
} else {
AxisEngine.send(rmc);
}
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:24,代码来源:CarbonEventingMessageReceiver.java
示例10: handleIncomingMessage
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
/**
* Process a new incoming message (Response) through the axis engine
* @param msgCtx the axis MessageContext
* @param trpHeaders the map containing transport level message headers
* @param soapAction the optional soap action or null
* @param contentType the optional content-type for the message
*/
public void handleIncomingMessage(
MessageContext msgCtx, Map trpHeaders,
String soapAction, String contentType) {
// set the soapaction if one is available via a transport header
if (soapAction != null) {
msgCtx.setSoapAction(soapAction);
}
// set the transport headers to the message context
msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, trpHeaders);
// send the message context through the axis engine
try {
try {
AxisEngine.receive(msgCtx);
} catch (AxisFault e) {
if (log.isDebugEnabled()) {
log.debug("Error receiving message", e);
}
if (msgCtx.isServerSide()) {
AxisEngine.sendFault(MessageContextBuilder.createFaultMessageContext(msgCtx, e));
}
}
} catch (AxisFault axisFault) {
logException("Error processing response message", axisFault);
}
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:36,代码来源:AbstractTransportSender.java
示例11: 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);
}
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:16,代码来源:TCPWorker.java
示例12: 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);
}
}
}
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:29,代码来源:XMPPPacketListener.java
示例13: 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);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:41,代码来源:FaultSerializationTest.java
示例14: 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);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:32,代码来源:AxisServlet.java
示例15: invokeBusinessLogic
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
public final void invokeBusinessLogic(MessageContext msgContext) throws AxisFault {
MessageContext outMsgContext = MessageContextBuilder.createOutMessageContext(msgContext);
outMsgContext.getOperationContext().addMessageContext(outMsgContext);
invokeBusinessLogic(msgContext, outMsgContext);
replicateState(msgContext);
AxisEngine.send(outMsgContext);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:10,代码来源:AbstractInOutMessageReceiver.java
示例16: handleIncomingMessage
import org.apache.axis2.util.MessageContextBuilder; //导入依赖的package包/类
/**
* Process a new incoming message through the axis engine
* @param msgCtx the axis MessageContext
* @param trpHeaders the map containing transport level message headers
* @param soapAction the optional soap action or null
* @param contentType the optional content-type for the message
*/
public void handleIncomingMessage(
MessageContext msgCtx, Map trpHeaders,
String soapAction, String contentType) throws AxisFault {
// set the soapaction if one is available via a transport header
if (soapAction != null) {
msgCtx.setSoapAction(soapAction);
}
// set the transport headers to the message context
msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, trpHeaders);
// send the message context through the axis engine
try {
// check if an Axis2 callback has been registered for this message
Map callBackMap = (Map) msgCtx.getConfigurationContext().
getProperty(BaseConstants.CALLBACK_TABLE);
// FIXME: transport headers are protocol specific; the correlation ID should be
// passed as argument to this method
Object replyToMessageID = trpHeaders.get(BaseConstants.HEADER_IN_REPLY_TO);
// if there is a callback registerd with this replyto ID then this has to
// be handled as a synchronous incoming message, via the
if (replyToMessageID != null && callBackMap != null &&
callBackMap.get(replyToMessageID) != null) {
SynchronousCallback synchronousCallback =
(SynchronousCallback) callBackMap.get(replyToMessageID);
synchronousCallback.setInMessageContext(msgCtx);
callBackMap.remove(replyToMessageID);
} else {
AxisEngine.receive(msgCtx);
}
} catch (AxisFault e) {
if (log.isDebugEnabled()) {
log.debug("Error receiving message", e);
}
if (msgCtx.isServerSide()) {
AxisEngine.sendFault(MessageContextBuilder.createFaultMessageContext(msgCtx, e));
}
}
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:50,代码来源:AbstractTransportListener.java
示例17: 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);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:12,代码来源:AxisEngine.java
注:本文中的org.apache.axis2.util.MessageContextBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论