本文整理汇总了Java中org.apache.axis2.context.MessageContext类的典型用法代码示例。如果您正苦于以下问题:Java MessageContext类的具体用法?Java MessageContext怎么用?Java MessageContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageContext类属于org.apache.axis2.context包,在下文中一共展示了MessageContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeBusinessLogic
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
/**
* Invokes the service by calling the script function
*/
public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault {
try {
log.debug("invoking script service");
outMC.setEnvelope(getSOAPFactory(inMC).getDefaultEnvelope());
BSFEngine engine = getBSFEngine(inMC);
OMElementConvertor convertor = (OMElementConvertor) inMC.getServiceContext().getProperty(CONVERTOR_PROP);
Parameter scriptFunctionParam = inMC.getAxisService().getParameter(FUNCTION_ATTR);
String scriptFunction = scriptFunctionParam == null ? DEFAULT_FUNCTION : (String) scriptFunctionParam.getValue();
ScriptMessageContext inScriptMC = new ScriptMessageContext(inMC, convertor);
ScriptMessageContext outScriptMC = new ScriptMessageContext(outMC, convertor);
Object[] args = new Object[] { inScriptMC, outScriptMC };
engine.call(null, scriptFunction, args);
} catch (BSFException e) {
throw AxisFault.makeFault(e);
}
}
示例2: getResponse
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
private SOAPEnvelope getResponse(SOAPEnvelope inEnvelope) throws AxisFault {
ConfigurationContext confctx = ConfigurationContextFactory.
createConfigurationContextFromFileSystem(TestingUtils.prefixBaseDirectory("target/test-resources/integrationRepo"),
null);
ServiceClient client = new ServiceClient(confctx, null);
Options options = new Options();
client.setOptions(options);
options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
options.setTo(targetEPR);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setExceptionToBeThrownOnSOAPFault(false);
MessageContext msgctx = new MessageContext();
msgctx.setEnvelope(inEnvelope);
OperationClient opClient = client.createClient(ServiceClient.ANON_OUT_IN_OP);
opClient.addMessageContext(msgctx);
opClient.execute(true);
return opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE).getEnvelope();
}
示例3: createDefaultSOAPEnvelope
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
private SOAPEnvelope createDefaultSOAPEnvelope(MessageContext inMsgCtx) {
String soapNamespace = inMsgCtx.getEnvelope().getNamespace()
.getNamespaceURI();
SOAPFactory soapFactory = null;
if (soapNamespace.equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
soapFactory = OMAbstractFactory.getSOAP11Factory();
} else if (soapNamespace
.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
soapFactory = OMAbstractFactory.getSOAP12Factory();
} else {
log.error("Unknown SOAP Envelope");
}
if (soapFactory != null) {
return soapFactory.getDefaultEnvelope();
}
return null;
}
示例4: getUsernameTokenPrincipal
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
/**
* Returns the UsernameTokenPrincipal from the security results.
*
* @param mc The message context of the message
* @return the UsernameTokenPrincipal from the security results as an
* <code>org.apache.ws.security.WSUsernameTokenPrincipal</code>.
* If a wsse:UsernameToken was not present in the wsse:Security header then
* <code>null</code> will be returned.
* @throws Exception If there are no security results.
* @see org.apache.ws.security.WSUsernameTokenPrincipal
*/
public static WSUsernameTokenPrincipal getUsernameTokenPrincipal(
MessageContext mc) throws Exception {
Vector results;
if ((results = (Vector) mc.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
throw new Exception("No security results available in the message context");
} else {
for (int i = 0; i < results.size(); i++) {
WSHandlerResult rResult = (WSHandlerResult) results.get(i);
Vector wsSecEngineResults = rResult.getResults();
for (int j = 0; j < wsSecEngineResults.size(); j++) {
WSSecurityEngineResult wser =
(WSSecurityEngineResult) wsSecEngineResults.get(j);
Integer actInt = (Integer) wser
.get(WSSecurityEngineResult.TAG_ACTION);
if (actInt.intValue() == WSConstants.UT) {
return (WSUsernameTokenPrincipal) wser
.get(WSSecurityEngineResult.TAG_PRINCIPAL);
}
}
}
}
return null;
}
示例5: getBasicAuthHeaders
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
/**
* Utility method to return basic auth transport headers if present
*
* @return
*/
private String getBasicAuthHeaders(MessageContext msgCtx) {
Map map = (Map) msgCtx.getProperty(MessageContext.TRANSPORT_HEADERS);
if (map == null) {
return null;
}
String tmp = (String) map.get("Authorization");
if (tmp == null) {
tmp = (String) map.get("authorization");
}
if (tmp != null && tmp.trim().startsWith("Basic ")) {
return tmp;
} else {
return null;
}
}
示例6: setMessageContext
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
/**
* creating the message context of the soap message
*
* @param addUrl
* @param trpUrl
* @param action
*/
private void setMessageContext(String addUrl, String trpUrl, String action) {
outMsgCtx = new MessageContext();
//assigning message context’s option object into instance variable
Options options = outMsgCtx.getOptions();
//setting properties into option
if (trpUrl != null && !"null".equals(trpUrl)) {
options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
}
if (addUrl != null && !"null".equals(addUrl)) {
options.setTo(new EndpointReference(addUrl));
}
if(action != null && !"null".equals(action)) {
options.setAction(action);
}
}
示例7: extractSessionID
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
protected String extractSessionID(MessageContext axis2MessageContext) {
Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o instanceof Map) {
Map headerMap = (Map) o;
String cookie = (String) headerMap.get(SET_COOKIE);
if (cookie == null) {
cookie = (String) headerMap.get(COOKIE);
} else {
cookie = cookie.split(";")[0];
}
return cookie;
}
return null;
}
示例8: extractSessionID
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
protected String extractSessionID(MessageContext axis2MessageContext) {
Object o = axis2MessageContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (o != null && o instanceof Map) {
Map headerMap = (Map) o;
String cookie = (String) headerMap.get(SET_COOKIE);
if (cookie == null) {
cookie = (String) headerMap.get(COOKIE);
} else {
cookie = cookie.split(";")[0];
}
return cookie;
}
return null;
}
示例9: gzipCompressionInsideOutSequenceTest
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "having 'Content-Encoding = gzip' within outsequence")
public void gzipCompressionInsideOutSequenceTest() throws Exception {
ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendingGZIPCompressedPayloadToClient"));
client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
OperationContext operationContext = client.getLastOperationContext();
MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
Assert.assertTrue(response.toString().contains("GZIP"));
Assert.assertTrue(response.toString().contains("GZIP Company"));
}
示例10: greet
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
public String greet(String name) {
ServiceContext serviceContext =
MessageContext.getCurrentMessageContext().getServiceContext();
serviceContext.setProperty(HELLO_SERVICE_NAME, name);
try {
Replicator.replicate(serviceContext, new String[]{HELLO_SERVICE_NAME});
} catch (ClusteringFault clusteringFault) {
clusteringFault.printStackTrace();
}
if (name != null) {
return "Hello World, " + name + " !!!";
} else {
return "Hello World !!!";
}
}
示例11: 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);
}
}
}
示例12: isHandle
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
/**
* Checks whether the authentication of the context can be handled using this authenticator.
*
* @param messageContext containing the request need to be authenticated.
* @return boolean indicating whether the request can be authenticated by this Authenticator.
*/
public boolean isHandle(MessageContext messageContext) {
HttpServletRequest httpServletRequest = getHttpRequest(messageContext);
if (httpServletRequest != null) {
String headerValue = httpServletRequest.getHeader(HTTPConstants.HEADER_AUTHORIZATION);
if (headerValue != null && !headerValue.trim().isEmpty()) {
String[] headerPart = headerValue.trim().split(OauthAuthenticatorConstants.SPLITING_CHARACTOR);
if (OauthAuthenticatorConstants.AUTHORIZATION_HEADER_PREFIX_BEARER.equals(headerPart[0])) {
return true;
}
} else if (httpServletRequest.getParameter(OauthAuthenticatorConstants.BEARER_TOKEN_IDENTIFIER) != null) {
return true;
}
}
return false;
}
示例13: SoapHeader
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
public SoapHeader(MessageContext messageContext) {
env = null;
hdr = null;
to = null;
action = null;
isSOAP12 = false;
isSOAP11 = false;
env = messageContext.getEnvelope();
if (env == null) return;
ns = env.getNamespace();
if (ns != null) {
isSOAP12 = ns.getNamespaceURI().contains("http://www.w3.org/2003/05/soap-envelope");
isSOAP11 = ns.getNamespaceURI().contains("http://schemas.xmlsoap.org/soap/envelope/");
}
hdr = MetadataSupport.firstChildWithLocalName(env, "Header");
if (hdr == null) return;
to = MetadataSupport.firstChildWithLocalName(hdr, "To");
action = MetadataSupport.firstChildWithLocalName(hdr, "Action");
}
示例14: SubmitObjectsRequest
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
public SubmitObjectsRequest(LogMessage log_message, short xds_version, MessageContext messageContext) {
this.log_message = log_message;
this.xds_version = xds_version;
this.clientIPAddress = null;
transaction_type = R_transaction;
try {
IheHTTPServer httpServer = (IheHTTPServer)messageContext.getTransportIn().getReceiver();
IheActor actor = httpServer.getIheActor();
if (actor == null) {
throw new XdsInternalException("Cannot find XdsRegistry actor configuration.");
}
connection = actor.getConnection();
if (connection == null) {
throw new XdsInternalException("Cannot find XdsRegistry connection configuration.");
}
auditLog = actor.getAuditTrail();
init(new RegistryResponse( (xds_version == xds_a) ? Response.version_2 : Response.version_3), xds_version, messageContext);
loadSourceIds();
} catch (XdsInternalException e) {
logger.fatal(logger_exception_details(e));
}
}
示例15: auditLog
import org.apache.axis2.context.MessageContext; //导入依赖的package包/类
/**
* Audit Logging of Register Document Set message.
*/
private void auditLog(String patientId, String submissionSetUid, AuditCodeMappings.AuditTypeCodes typeCode) {
if (auditLog == null)
return;
String replyto = getMessageContext().getReplyTo().getAddress();
String remoteIP = (String)getMessageContext().getProperty(MessageContext.REMOTE_ADDR);
String localIP = (String)getMessageContext().getProperty(MessageContext.TRANSPORT_ADDR);
ParticipantObject set = new ParticipantObject("SubmissionSet", submissionSetUid);
ParticipantObject patientObj = new ParticipantObject("PatientIdentifier", patientId);
ActiveParticipant source = new ActiveParticipant();
source.setUserId(replyto);
source.setAccessPointId(remoteIP);
//TODO: Needs to be improved
String userid = "http://"+connection.getHostname()+":"+connection.getPort()+"/axis2/services/xdsregistryb";
ActiveParticipant dest = new ActiveParticipant();
dest.setUserId(userid);
// the Alternative User ID should be set to our Process ID, see
// section TF-2b section 3.42.7.1.2
dest.setAltUserId(PidHelper.getPid());
dest.setAccessPointId(localIP);
auditLog.logDocumentImport(source, dest, patientObj, set, typeCode);
}