本文整理汇总了Java中org.apache.axis2.context.MessageContext.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setProperty方法的具体用法?Java MessageContext.setProperty怎么用?Java MessageContext.setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.setProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected MessageContext send(ClientOptions options, AxisMessage message, QName operationQName,
boolean block, String resultMessageLabel) throws Exception {
OperationClient mepClient = serviceClient.createClient(operationQName);
MessageContext mc = new MessageContext();
mc.setProperty(Constants.Configuration.MESSAGE_TYPE, message.getMessageType());
mc.setEnvelope(message.getEnvelope());
Attachments attachments = message.getAttachments();
if (attachments != null) {
mc.setAttachmentMap(attachments);
mc.setDoingSwA(true);
mc.setProperty(Constants.Configuration.ENABLE_SWA, true);
}
for (AxisTestClientConfigurator configurator : configurators) {
configurator.setupRequestMessageContext(mc);
}
mc.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, options.getCharset());
mc.setServiceContext(serviceClient.getServiceContext());
if (metrics != null) {
mc.setProperty(BaseConstants.METRICS_COLLECTOR, metrics);
}
mepClient.addMessageContext(mc);
mepClient.execute(block);
// mepClient.complete(mc);
return resultMessageLabel == null ? null : mepClient.getMessageContext(resultMessageLabel);
}
示例2: dispatchAndVerify
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Finds axis Service and the Operation for DSS requests
*
* @param msgContext request message context
* @throws AxisFault if any exception occurs while finding axis service or operation
*/
private static void dispatchAndVerify(MessageContext msgContext) throws AxisFault {
requestDispatcher.invoke(msgContext);
AxisService axisService = msgContext.getAxisService();
if (axisService != null) {
httpLocationBasedDispatcher.invoke(msgContext);
if (msgContext.getAxisOperation() == null) {
requestURIOperationDispatcher.invoke(msgContext);
}
AxisOperation axisOperation;
if ((axisOperation = msgContext.getAxisOperation()) != null) {
AxisEndpoint axisEndpoint =
(AxisEndpoint) msgContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
if (axisEndpoint != null) {
AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisEndpoint
.getBinding().getChild(axisOperation.getName());
msgContext.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
}
msgContext.setAxisOperation(axisOperation);
}
}
}
示例3: setUnprocessedHeaders
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void setUnprocessedHeaders(MessageContext messageContext, RolePlayer rolePlayer) {
SOAPEnvelope envelope = messageContext.getEnvelope();
Iterator headerBlocks = envelope.getHeader().getHeadersToProcess(rolePlayer);
List<QName> unprocessedHeaders = new ArrayList<QName>();
while (headerBlocks.hasNext()) {
SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
QName headerName = headerBlock.getQName();
// if this header block has been processed or mustUnderstand isn't
// turned on then its cool
if (headerBlock.isProcessed() || !headerBlock.getMustUnderstand()) {
continue;
} else {
unprocessedHeaders.add(headerName);
}
}
if(unprocessedHeaders !=null && unprocessedHeaders.size()>0){
messageContext.setProperty(Constants.UNPROCESSED_HEADER_QNAMES, unprocessedHeaders);
}
}
示例4: run
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void run() {
MetricsCollector metrics = endpoint.getMetrics();
try {
InputStream inputStream = new ByteArrayInputStream(data, 0, length);
MessageContext msgContext = endpoint.createMessageContext();
SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext, inputStream, endpoint.getContentType());
msgContext.setEnvelope(envelope);
if (outInfo != null) {
if (outInfo.getContentType() == null) {
outInfo.setContentType(endpoint.getContentType());
}
msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outInfo);
}
AxisEngine.receive(msgContext);
metrics.incrementMessagesReceived();
metrics.incrementBytesReceived(length);
} catch (Exception ex) {
metrics.incrementFaultsReceiving();
StringBuilder buffer = new StringBuilder("Error during processing of datagram:\n");
Utils.hexDump(buffer, data, length);
log.error(buffer.toString(), ex);
}
}
示例5: setAuthHeaders
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void setAuthHeaders(MessageContext msgCtx) throws IOException {
String serverName = ServerConfiguration.getInstance().getFirstProperty("Name");
if (serverName == null || serverName.trim().length() == 0) {
serverName = "WSO2 Carbon";
}
HttpServletResponse response = (HttpServletResponse)
msgCtx.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
// TODO : verify this fix. This is to handle soap fault from UT scenario
if (msgCtx.isFault() && response == null) {
MessageContext originalContext = (MessageContext) msgCtx.getProperty(MessageContext.IN_MESSAGE_CONTEXT);
if (originalContext != null) {
response = (HttpServletResponse)
originalContext.getProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE);
}
}
if (response != null) {
if (msgCtx.getProperty(MESSAGE_TYPE) != null) {
response.setContentType(String.valueOf(msgCtx.getProperty(MESSAGE_TYPE)));
}
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.addHeader("WWW-Authenticate",
"BASIC realm=\"" + serverName + "\"");
response.flushBuffer();
} else {
// if not servlet transport assume it to be nhttp transport
msgCtx.setProperty("NIO-ACK-Requested", "true");
msgCtx.setProperty("HTTP_SC", HttpServletResponse.SC_UNAUTHORIZED);
Map<String, String> responseHeaders = new HashMap<>();
responseHeaders.put("WWW-Authenticate",
"BASIC realm=\"" + serverName + "\"");
msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, responseHeaders);
}
}
示例6: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* This method gets the JWT token from the transport header, and extracts the user name from the JWT and
* sets it to the message context.
*
* @param arg0
*/
public InvocationResponse invoke(MessageContext arg0) throws AxisFault {
HttpServletRequest obj = (HttpServletRequest) arg0.
getProperty(HTTP_SERVLET_REQUEST);
if (obj != null) {
//Get the "username" from the header.
String username = obj.getHeader(USERNAME);
arg0.setProperty(USERNAME, username);
log.debug("********************** Username from msgcontext - "+arg0.getProperty(USERNAME));
}
return InvocationResponse.CONTINUE;
}
示例7: setSessionID
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected void setSessionID(MessageContext axis2MessageContext, String value) {
if (value == null) {
return;
}
Map map = (Map) axis2MessageContext.getProperty(HTTPConstants.HTTP_HEADERS);
if (map == null) {
map = new HashMap();
axis2MessageContext.setProperty(HTTPConstants.HTTP_HEADERS, map);
}
map.put(COOKIE, value);
}
示例8: uploadFileUsingSwA
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement uploadFileUsingSwA(OMElement request) throws Exception {
String imageContentId = request.
getFirstChildWithName(new QName("http://services.samples", "request")).
getFirstChildWithName(new QName("http://services.samples", "imageId")).
getText();
MessageContext msgCtx = MessageContext.getCurrentMessageContext();
Attachments attachment = msgCtx.getAttachmentMap();
DataHandler dataHandler = attachment.getDataHandler(imageContentId);
File tempFile = File.createTempFile("swa-", ".gif");
FileOutputStream fos = new FileOutputStream(tempFile);
dataHandler.writeTo(fos);
fos.flush();
fos.close();
System.out.println("Wrote SwA attachment to temp file : " + tempFile.getAbsolutePath());
MessageContext outMsgCtx = msgCtx.getOperationContext().
getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
outMsgCtx.setProperty(
org.apache.axis2.Constants.Configuration.ENABLE_SWA,
org.apache.axis2.Constants.VALUE_TRUE);
OMFactory factory = request.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
OMElement payload = factory.createOMElement("uploadFileUsingSwAResponse", ns);
OMElement response = factory.createOMElement("response", ns);
OMElement imageId = factory.createOMElement("imageId", ns);
FileDataSource fileDataSource = new FileDataSource(tempFile);
dataHandler = new DataHandler(fileDataSource);
imageContentId = outMsgCtx.addAttachment(dataHandler);
imageId.setText(imageContentId);
response.addChild(imageId);
payload.addChild(response);
return payload;
}
示例9: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
System.out.println("MessageSaveAndRestoreWithMTOMTest:Inbound handler invoked");
if (messageContext.getProperty(stateProperty) == null) {
System.out.println("MessageSaveAndRestoreWithMTOMTest:Suspending processing");
messageContext.setProperty(stateProperty, new Object());
messageContext.pause();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
ObjectOutputStream objectOutputStream =
new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(messageContext);
objectOutputStream.flush();
objectOutputStream.close();
byteArrayOutputStream.flush();
byteArrayOutputStream.close();
}
catch (IOException e) {
e.printStackTrace();
fail("An error occurred when serializing the MessageContext");
}
new Worker(byteArrayOutputStream.toByteArray(),
messageContext.getConfigurationContext()).start();
} else {
System.out.println(
"MessageSaveAndRestoreWithMTOMTest:Skipping previously invoked Inbound handler");
}
return InvocationResponse.CONTINUE;
}
示例10: 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;
}
示例11: setupUsernameToken
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Sets the message context properties for adding a UsernameToken to the security header.
* <p>Because other elements that need to be added to the header may also require a password the password callback
* handler is not created in this method, but shared for the header.
*
* @param mc The {@link MessageContext} to set up
* @param utConfig The configuration for the username token
* @param pwdCBHandler The {@link PasswordCallbackHandler} to use for handing over the password to WSS4J library
*/
private void setupUsernameToken(final MessageContext mc, final IUsernameTokenConfiguration utConfig,
final PasswordCallbackHandler pwdCBHandler) {
mc.setProperty(ConfigurationConstants.USER, utConfig.getUsername());
mc.setProperty(ConfigurationConstants.ADD_USERNAMETOKEN_CREATED, Boolean.toString(utConfig.includeCreated()));
mc.setProperty(ConfigurationConstants.ADD_USERNAMETOKEN_NONCE, Boolean.toString(utConfig.includeNonce()));
mc.setProperty(ConfigurationConstants.PASSWORD_TYPE,
utConfig.getPasswordType() == IUsernameTokenConfiguration.PasswordType.DIGEST ?
WSConstants.PW_DIGEST : WSConstants.PW_TEXT);
pwdCBHandler.addUser(utConfig.getUsername(), utConfig.getPassword());
}
示例12: getRegistryWithoutSession
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void getRegistryWithoutSession() throws Exception {
UserRegistry userRegistry = mock(UserRegistry.class);
MessageContext messageContext = new MessageContext();
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
HttpSession session = mock(HttpSession.class);
when(session.getAttribute(RegistryConstants.USER_REGISTRY)).thenReturn(userRegistry);
when(servletRequest.getSession()).thenReturn(session);
messageContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, servletRequest);
MessageContext.setCurrentMessageContext(messageContext);
assertEquals(userRegistry, CommonUtil.getRegistry(null));
}
示例13: testValidateActionFlag
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testValidateActionFlag() throws Exception {
MessageContext mc = new MessageContext();
//Indicate that the AddressingInHandler has run.
mc.setProperty(AddressingConstants.IS_ADDR_INFO_ALREADY_PROCESSED, Boolean.TRUE);
// Tell validation handler NOT to check action dispatch
mc.setProperty(AddressingConstants.ADDR_VALIDATE_ACTION, Boolean.FALSE);
// Even though this message has an action that will not dispatch to an
// AxisOperation, this shouldn't throw a fault.
AddressingBasedDispatcher dispatcher = new AddressingBasedDispatcher();
dispatcher.invoke(mc);
}
示例14: updateCurrentInvocationGlobalStatistics
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* This method is used to update current request statistic , this statistics useful for bam to define SLAs using CEP
* RequestCount =1
* ResponseCount = 1
* FaultCount = 0
* @param outMsgContext
*/
private void updateCurrentInvocationGlobalStatistics(MessageContext outMsgContext) throws AxisFault {
//Set request count 1
outMsgContext.setProperty(StatisticsConstants.GLOBAL_CURRENT_REQUEST_COUNTER,1);
//Set response count 1
outMsgContext.setProperty(StatisticsConstants.GLOBAL_CURRENT_RESPONSE_COUNTER,1);
//Set fault count 0
outMsgContext.setProperty(StatisticsConstants.GLOBAL_CURRENT_FAULT_COUNTER,0);
}
示例15: handleIncomingMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的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);
}
}