本文整理汇总了Java中org.apache.axis2.context.MessageContext.setServerSide方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setServerSide方法的具体用法?Java MessageContext.setServerSide怎么用?Java MessageContext.setServerSide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.setServerSide方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Create a new axis MessageContext for an incoming message through this transport
* @return the newly created message context
*/
public MessageContext createMessageContext() {
MessageContext msgCtx = new MessageContext();
msgCtx.setConfigurationContext(cfgCtx);
msgCtx.setIncomingTransportName(getTransportName());
msgCtx.setTransportOut(transportOut);
msgCtx.setTransportIn(transportIn);
msgCtx.setServerSide(true);
msgCtx.setMessageID(UUIDGenerator.getUUID());
// There is a discrepency in what I thought, Axis2 spawns a nes threads to
// send a message is this is TRUE - and I want it to be the other way
msgCtx.setProperty(MessageContext.CLIENT_API_NON_BLOCKING, Boolean.valueOf(!isNonBlocking));
// are these relevant?
//msgCtx.setServiceGroupContextId(UUIDGenerator.getUUID());
// this is required to support Sandesha 2
//msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
// new HttpCoreRequestResponseTransport(msgContext));
return msgCtx;
}
示例2: send
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Synchronously send the request and receive a response. This relies on the transport correctly connecting the
* response InputStream!
*
* @param msgContext the request MessageContext to send.
* @return Returns MessageContext.
* @throws AxisFault Sends the message using a two way transport and waits for a response
*/
protected MessageContext send(final MessageContext msgContext) throws AxisFault {
// create the responseMessageContext
final MessageContext responseMessageContext
= msgContext.getConfigurationContext().createMessageContext();
responseMessageContext.setServerSide(false);
responseMessageContext.setOperationContext(msgContext.getOperationContext());
responseMessageContext.setOptions(new Options(options));
responseMessageContext.setMessageID(msgContext.getMessageID());
addMessageContext(responseMessageContext);
responseMessageContext.setServiceContext(msgContext.getServiceContext());
responseMessageContext.setAxisMessage(
axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
//sending the message
AxisEngine.send(msgContext);
responseMessageContext.setDoingREST(msgContext.isDoingREST());
// Copy RESPONSE properties which the transport set onto the request message context when it processed
// the incoming response recieved in reply to an outgoing request.
responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));
responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
.getProperty(MessageContext.TRANSPORT_IN));
responseMessageContext.setTransportIn(msgContext.getTransportIn());
responseMessageContext.setTransportOut(msgContext.getTransportOut());
handleResponse(responseMessageContext);
return responseMessageContext;
}
示例3: send
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Synchronously send the request and receive a response. This relies on the transport
* correctly connecting the response InputStream!
*
* @param msgContext the request MessageContext to send.
* @return Returns MessageContext.
* @throws AxisFault Sends the message using a two way transport and waits for a response
*/
protected MessageContext send(MessageContext msgContext) throws AxisFault {
// create the responseMessageContext
MessageContext responseMessageContext =
msgContext.getConfigurationContext().createMessageContext();
responseMessageContext.setServerSide(false);
responseMessageContext.setOperationContext(msgContext.getOperationContext());
responseMessageContext.setOptions(new Options(options));
responseMessageContext.setMessageID(msgContext.getMessageID());
addMessageContext(responseMessageContext);
responseMessageContext.setServiceContext(msgContext.getServiceContext());
responseMessageContext.setAxisMessage(
axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
//sending the message
AxisEngine.send(msgContext);
responseMessageContext.setDoingREST(msgContext.isDoingREST());
// Copy RESPONSE properties which the transport set onto the request message context when it processed
// the incoming response recieved in reply to an outgoing request.
responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));
responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
.getProperty(MessageContext.TRANSPORT_IN));
responseMessageContext.setTransportIn(msgContext.getTransportIn());
responseMessageContext.setTransportOut(msgContext.getTransportOut());
handleResponse(responseMessageContext);
return responseMessageContext;
}
示例4: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc, ConfigurationContext cc,
int flowType) throws Exception {
MessageContext mc = cc.createMessageContext();
mc.setFLOW(flowType);
mc.setTransportIn(transportIn);
mc.setTransportOut(transportOut);
mc.setServerSide(true);
// mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);
SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
mc.setEnvelope(omFac.getDefaultEnvelope());
AxisOperation axisOperation = oc.getAxisOperation();
String action = axisOperation.getName().getLocalPart();
mc.setSoapAction(action);
// System.out.flush();
mc.setMessageID(UUIDGenerator.getUUID());
axisOperation.registerOperationContext(mc, oc);
mc.setOperationContext(oc);
ServiceContext sc = oc.getServiceContext();
mc.setServiceContext(sc);
mc.setTo(new EndpointReference("axis2/services/NullService"));
mc.setWSAAction("DummyOp");
AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
mc.setAxisMessage(axisMessage);
return mc;
}
示例5: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc) throws Exception {
MessageContext mc = configurationContext.createMessageContext();
mc.setTransportIn(transportIn);
mc.setTransportOut(transportOut);
mc.setServerSide(true);
// mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);
SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
mc.setEnvelope(omFac.getDefaultEnvelope());
AxisOperation axisOperation = oc.getAxisOperation();
String action = axisOperation.getName().getLocalPart();
mc.setSoapAction(action);
// System.out.flush();
mc.setMessageID(UUIDGenerator.getUUID());
axisOperation.registerOperationContext(mc, oc);
mc.setOperationContext(oc);
ServiceContext sc = oc.getServiceContext();
mc.setServiceContext(sc);
mc.setTo(new EndpointReference("axis2/services/NullService"));
mc.setWSAAction("DummyOp");
AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
mc.setAxisMessage(axisMessage);
return mc;
}
示例6: testDifferentSoapActionProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testDifferentSoapActionProcessing() throws Exception {
String testfile = "valid-messages/" + versionDirectory + "/soapmessage.xml";
MessageContext mc = new MessageContext();
mc.setConfigurationContext(ConfigurationContextFactory.createEmptyConfigurationContext());
mc.setServerSide(true);
try {
mc.setSoapAction("http://ws.apache.org/tests/differentAction");
basicExtractAddressingInformationFromHeaders(testfile, mc);
fail("An AxisFault should have been thrown due to the soapaction being different to the ws-a action.");
}
catch (AxisFault af) {
//Test passed.
}
}
示例7: testSameSoapAction
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testSameSoapAction() throws Exception {
String testfile = "valid-messages/" + versionDirectory + "/soapmessage.xml";
MessageContext mc = new MessageContext();
mc.setConfigurationContext(ConfigurationContextFactory.createEmptyConfigurationContext());
mc.setServerSide(true);
try {
mc.setSoapAction("http://ws.apache.org/tests/action");
basicExtractAddressingInformationFromHeaders(testfile, mc);
}
catch (AxisFault af) {
af.printStackTrace();
log.error(af.getMessage());
fail("An unexpected AxisFault was thrown while testing with a soapaction and ws-a action that are the same.");
}
}
示例8: initializeMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static int initializeMessageContext(MessageContext msgContext,
String soapActionHeader,
String requestURI,
String contentType) {
int soapVersion = VERSION_UNKNOWN;
// remove the starting and trailing " from the SOAP Action
if ((soapActionHeader != null)
&& soapActionHeader.length() > 0
&& soapActionHeader.charAt(0) == '\"'
&& soapActionHeader.endsWith("\"")) {
soapActionHeader = soapActionHeader.substring(1, soapActionHeader.length() - 1);
}
// fill up the Message Contexts
msgContext.setSoapAction(soapActionHeader);
msgContext.setTo(new EndpointReference(requestURI));
msgContext.setServerSide(true);
// get the type of char encoding
String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
if (charSetEnc == null) {
charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
}
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
if (contentType != null) {
if (contentType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) > -1) {
soapVersion = VERSION_SOAP12;
TransportUtils.processContentTypeForAction(contentType, msgContext);
} else if (contentType
.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
soapVersion = VERSION_SOAP11;
} else if (isRESTRequest(contentType)) {
// If REST, construct a SOAP11 envelope to hold the rest message and
// indicate that this is a REST message.
soapVersion = VERSION_SOAP11;
msgContext.setDoingREST(true);
}
if (soapVersion == VERSION_SOAP11) {
// TODO Keith : Do we need this anymore
// Deployment configuration parameter
Parameter disableREST = msgContext
.getParameter(Constants.Configuration.DISABLE_REST);
if (soapActionHeader == null && disableREST != null) {
if (Constants.VALUE_FALSE.equals(disableREST.getValue())) {
// If the content Type is text/xml (BTW which is the
// SOAP 1.1 Content type ) and the SOAP Action is
// absent it is rest !!
msgContext.setDoingREST(true);
}
}
}
}
return soapVersion;
}
示例9: testDoProcessingOfTheUserMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfTheUserMessage() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
UserMessage userMessage = UserMessageElement.readElement(umElement);
String pmodeId =
userMessage.getCollaborationInfo().getAgreement().getPModeId();
userMessage.setPModeId(pmodeId);
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.OUT_FLOW);
// Setting input message property
IUserMessageEntity userMessageEntity =
core.getStorageManager().storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.OUT_USER_MESSAGE,
userMessageEntity);
// Mocking the Axis2 Operation Context
OperationContext operationContext = mock(OperationContext.class);
when(operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
.thenReturn(mc);
mc.setOperationContext(operationContext);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertNotNull(invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "Response contains an user message unit";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例10: testDoProcessingOfTheResponseReceipt
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfTheResponseReceipt() throws Exception {
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.OUT_FLOW);
Receipt receipt = new Receipt();
OMElement receiptChildElement =
env.getOMFactory().createOMElement(RECEIPT_CHILD_ELEMENT_NAME);
ArrayList<OMElement> content = new ArrayList<>();
content.add(receiptChildElement);
receipt.setContent(content);
ReceiptElement.createElement(headerBlock, receipt);
StorageManager updateManager = core.getStorageManager();
IReceiptEntity receiptEntity =
updateManager.storeIncomingMessageUnit(receipt);
mc.setProperty(MessageContextProperties.RESPONSE_RECEIPT, receiptEntity);
// Mocking the Axis2 Operation Context
OperationContext operationContext = mock(OperationContext.class);
when(operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
.thenReturn(mc);
mc.setOperationContext(operationContext);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertNotNull(invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce())
.doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg = "Response contains a receipt signal";
assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
示例11: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
UserMessageElement.createElement(headerBlock, mmd);
String msgId = "some_msg_id";
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.IN_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
String errorId = "error_id";
ErrorMessage errorMessage = new ErrorMessage();
ArrayList<IEbmsError> errors = new ArrayList<>();
EbmsError ebmsError = new EbmsError();
ebmsError.setSeverity(IEbmsError.Severity.FAILURE);
ebmsError.setErrorCode("some_error_code");
ebmsError.setRefToMessageInError(msgId);
ebmsError.setMessage("some error message");
errors.add(ebmsError);
errorMessage.setErrors(errors);
errorMessage.setRefToMessageId(msgId);
errorMessage.setMessageId(errorId);
ErrorSignalElement.createElement(headerBlock, errorMessage);
assertNull(mc.getProperty(MessageContextProperties.IN_ERRORS));
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
assertNotNull(mc.getProperty(MessageContextProperties.IN_ERRORS));
}
示例12: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
UserMessageElement.createElement(headerBlock, mmd);
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.IN_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
// Setting input receipts property
Receipt receipt = new Receipt();
OMElement receiptChildElement =
env.getOMFactory().createOMElement(RECEIPT_CHILD_ELEMENT_NAME);
ArrayList<OMElement> content = new ArrayList<>();
content.add(receiptChildElement);
receipt.setContent(content);
receipt.setRefToMessageId("some_msg_id");
receipt.setMessageId("receipt_id");
ReceiptElement.createElement(headerBlock, receipt);
assertNull(mc.getProperty(MessageContextProperties.IN_RECEIPTS));
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
assertNotNull(mc.getProperty(MessageContextProperties.IN_RECEIPTS));
}
示例13: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
String msgId = "some_msg_id_01";
UserMessage userMessage = UserMessageElement.readElement(umElement);
String pmodeId =
userMessage.getCollaborationInfo().getAgreement().getPModeId();
userMessage.setPModeId(pmodeId);
userMessage.setMessageId(msgId);
PMode pmode = new PMode();
pmode.setMep(EbMSConstants.ONE_WAY_MEP);
pmode.setId(pmodeId);
Leg leg = new Leg();
leg.setUserMessageFlow(new UserMessageFlow());
pmode.addLeg(leg);
core.getPModeSet().add(pmode);
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.IN_FLOW);
StorageManager storageManager = core.getStorageManager();
// Setting input message property
IUserMessageEntity userMessageEntity =
storageManager.storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
userMessageEntity);
EbmsError error1 = new EbmsError();
error1.setRefToMessageInError(userMessageEntity.getMessageId());
error1.setErrorDetail("Some error for testing.");
// Adding generated error
MessageContextUtils.addGeneratedError(mc, error1);
// Mocking the Axis2 Operation Context
OperationContext operationContext = mock(OperationContext.class);
when(operationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
.thenReturn(mc);
mc.setOperationContext(operationContext);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce()).doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg1 = "This error signal should be sent as a response";
assertTrue(TestUtils.eventContainsMsg(events, Level.DEBUG, msg1));
}
示例14: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
PMode pmode = new PMode();
pmode.setMep(EbMSConstants.ONE_WAY_MEP);
String msgId = "org.holodeckb2b.ebms3.handlers.inflow.ProcessErrorsTest_01";
UserMessage userMessage = UserMessageElement.readElement(umElement);
String pmodeId =
userMessage.getCollaborationInfo().getAgreement().getPModeId();
userMessage.setPModeId(pmodeId);
userMessage.setMessageId(msgId);
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.IN_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
String errorId = "error_id";
ErrorMessage errorMessage = new ErrorMessage();
ArrayList<IEbmsError> errors = new ArrayList<>();
EbmsError ebmsError = new EbmsError();
ebmsError.setSeverity(IEbmsError.Severity.FAILURE);
ebmsError.setErrorCode("some_error_code");
ebmsError.setRefToMessageInError(msgId);
ebmsError.setMessage("some error message");
errors.add(ebmsError);
errorMessage.setErrors(errors);
errorMessage.setRefToMessageId(msgId);
errorMessage.setMessageId("error_id");
StorageManager storageManager = core.getStorageManager();
// Setting input message property
IUserMessageEntity userMessageEntity =
storageManager.storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
userMessageEntity);
// Setting input errors property
ErrorSignalElement.createElement(headerBlock, errorMessage);
IErrorMessageEntity errorMessageEntity =
storageManager.storeIncomingMessageUnit(errorMessage);
ArrayList<IErrorMessageEntity> errorMessageEntities = new ArrayList<>();
errorMessageEntities.add(errorMessageEntity);
mc.setProperty(MessageContextProperties.IN_ERRORS,
errorMessageEntities);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce()).doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg1 = "Processed Error Signal ["+errorId+"]";
assertTrue(TestUtils.eventContainsMsg(events, Level.DEBUG, msg1));
String msg2 = "All Error Signals processed";
assertTrue(TestUtils.eventContainsMsg(events, Level.DEBUG, msg2));
}
示例15: testDoProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
// Creating SOAP envelope
SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
// Adding header
SOAPHeaderBlock headerBlock = Messaging.createElement(env);
// Adding UserMessage from mmd
OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);
PMode pmode = new PMode();
pmode.setMep(EbMSConstants.ONE_WAY_MEP);
String msgId = "org.holodeckb2b.ebms3.handlers.inflow.ProcessReceiptsTest_01";
UserMessage userMessage = UserMessageElement.readElement(umElement);
String pmodeId =
userMessage.getCollaborationInfo().getAgreement().getPModeId();
userMessage.setPModeId(pmodeId);
userMessage.setMessageId(msgId);
pmode.setId(pmodeId);
MessageContext mc = new MessageContext();
mc.setServerSide(true);
mc.setFLOW(MessageContext.IN_FLOW);
try {
mc.setEnvelope(env);
} catch (AxisFault axisFault) {
fail(axisFault.getMessage());
}
Leg leg = new Leg();
ReceiptConfiguration receiptConfiguration = new ReceiptConfiguration();
leg.setReceiptConfiguration(receiptConfiguration);
pmode.addLeg(leg);
core.getPModeSet().add(pmode);
StorageManager storageManager = core.getStorageManager();
// Setting input message property
IUserMessageEntity userMessageEntity =
storageManager.storeIncomingMessageUnit(userMessage);
mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
userMessageEntity);
storageManager.setProcessingState(userMessageEntity, ProcessingState.AWAITING_RECEIPT);
// Setting input receipts property
Receipt receipt = new Receipt();
OMElement receiptChildElement =
env.getOMFactory().createOMElement(RECEIPT_CHILD_ELEMENT_NAME);
ArrayList<OMElement> content = new ArrayList<>();
content.add(receiptChildElement);
receipt.setContent(content);
receipt.setRefToMessageId(msgId);
receipt.setMessageId("receipt_id");
ReceiptElement.createElement(headerBlock, receipt);
IReceiptEntity receiptEntity =
storageManager.storeIncomingMessageUnit(receipt);
ArrayList<IReceiptEntity> receiptEntities = new ArrayList<>();
receiptEntities.add(receiptEntity);
mc.setProperty(MessageContextProperties.IN_RECEIPTS, receiptEntities);
try {
Handler.InvocationResponse invokeResp = handler.invoke(mc);
assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
} catch (Exception e) {
fail(e.getMessage());
}
verify(mockAppender, atLeastOnce()).doAppend(captorLoggingEvent.capture());
List<LoggingEvent> events = captorLoggingEvent.getAllValues();
String msg1 = "Mark Receipt as ready for delivery to business application";
assertTrue(TestUtils.eventContainsMsg(events, Level.DEBUG, msg1));
}