本文整理汇总了Java中org.apache.axis2.context.MessageContext.getTo方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getTo方法的具体用法?Java MessageContext.getTo怎么用?Java MessageContext.getTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.getTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
// is there a transport url which may be different to the WS-A To but has higher precedence
String targetAddress = (String) msgContext.getProperty(
Constants.Configuration.TRANSPORT_URL);
if (targetAddress != null) {
sendMessage(msgContext, targetAddress, null);
} else if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
targetAddress = msgContext.getTo().getAddress();
if (!msgContext.getTo().hasNoneAddress()) {
sendMessage(msgContext, targetAddress, null);
} else {
//Don't send the message.
return InvocationResponse.CONTINUE;
}
} else if (msgContext.isServerSide()) {
// get the out transport info for server side when target EPR is unknown
sendMessage(msgContext, null,
(OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO));
}
return InvocationResponse.CONTINUE;
}
示例2: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext)
throws AxisFault {
String targetAddress = (String) msgContext.getProperty(
Constants.Configuration.TRANSPORT_URL);
if (targetAddress != null) {
sendMessage(msgContext, targetAddress, null);
} else if (msgContext.getTo() != null && !msgContext.getTo().hasAnonymousAddress()) {
targetAddress = msgContext.getTo().getAddress();
if (!msgContext.getTo().hasNoneAddress()) {
sendMessage(msgContext, targetAddress, null);
} else {
//Don't send the message.
return InvocationResponse.CONTINUE;
}
} else if (msgContext.isServerSide()) {
// get the out transport info for server side when target EPR is unknown
sendMessage(msgContext, null,
(OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO));
}
return InvocationResponse.CONTINUE;
}
示例3: findOperation
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public AxisOperation findOperation(AxisService service, MessageContext messageContext)
throws AxisFault {
EndpointReference toEPR = messageContext.getTo();
if (toEPR != null) {
String filePart = toEPR.getAddress();
String operation = Utils.getOperationName(filePart, service.getName());
if (operation != null) {
QName operationName = new QName(operation);
log.debug(messageContext.getLogIDString() +
" Checking for Operation using QName(target endpoint URI fragment) : " +
operationName);
return service.getOperation(operationName);
} else {
log.debug(messageContext.getLogIDString() +
" Attempted to check for Operation using target endpoint URI, but the operation fragment was missing");
return null;
}
} else {
log.debug(messageContext.getLogIDString() +
" Attempted to check for Operation using null target endpoint URI");
return null;
}
}
示例4: validateTransport
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* To check whether the incoming request has come in valid transport , simply the transports
* that service author wants to expose
*
* @param msgctx the current MessageContext
* @throws AxisFault in case of error
*/
private void validateTransport(MessageContext msgctx) throws AxisFault {
AxisService service = msgctx.getAxisService();
if (service.isEnableAllTransports()) {
return;
} else {
List trs = service.getExposedTransports();
String incomingTrs = msgctx.getIncomingTransportName();
//local transport is a special case, it need not be exposed.
if (Constants.TRANSPORT_LOCAL.equals(incomingTrs)) {
return;
}
for (int i = 0; i < trs.size(); i++) {
String tr = (String) trs.get(i);
if (incomingTrs != null && incomingTrs.startsWith(tr)) {
return;
}
}
}
EndpointReference toEPR = msgctx.getTo();
throw new AxisFault(Messages.getMessage("servicenotfoundforepr",
((toEPR != null) ? toEPR.getAddress() : "")));
}
示例5: addReferenceParameters
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected void addReferenceParameters(MessageContext msgctx) {
EndpointReference to = msgctx.getTo();
if (options.isManageSession() || (options.getParent() != null &&
options.getParent().isManageSession())) {
EndpointReference tepr = sc.getTargetEPR();
if (tepr != null) {
Map<QName, OMElement> map = tepr.getAllReferenceParameters();
if (map != null) {
Iterator<OMElement> valuse = map.values().iterator();
while (valuse.hasNext()) {
Object refparaelement = valuse.next();
if (refparaelement instanceof OMElement) {
to.addReferenceParameter((OMElement) refparaelement);
}
}
}
}
}
}
示例6: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
if (log.isDebugEnabled()) {
log.debug("Invoking UnifiedEndpointHandler.");
}
UnifiedEndpoint unifiedEndpoint;
if (msgContext.getTo() instanceof UnifiedEndpoint) {
unifiedEndpoint = (UnifiedEndpoint) msgContext.getTo();
handleMessageOutput(unifiedEndpoint, msgContext);
handleAddressing(unifiedEndpoint, msgContext);
handleSecurity(unifiedEndpoint, msgContext);
handleTransportProperties(unifiedEndpoint, msgContext);
}
return InvocationResponse.CONTINUE;
}
示例7: extractTopicFromMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static String extractTopicFromMessage(MessageContext mc) throws WSEventException {
String topic = null;
if (mc.getTo() != null && mc.getTo().getAddress() != null) {
String toaddress = mc.getTo().getAddress();
if (toaddress.contains("/publish/")) {
Matcher matcher = EventingConstants.TO_ADDRESS_PATTERN.matcher(toaddress);
if (matcher.matches()) {
topic = matcher.group(1);
}
}
}
if ((topic == null) || (topic.trim().length() == 0)) {
try {
AXIOMXPath topicXPath = new AXIOMXPath(
"s11:Header/ns:" + EventingConstants.TOPIC_HEADER_NAME
+ " | s12:Header/ns:" + EventingConstants.TOPIC_HEADER_NAME);
topicXPath.addNamespace("s11", "http://schemas.xmlsoap.org/soap/envelope/");
topicXPath.addNamespace("s12", "http://www.w3.org/2003/05/soap-envelope");
topicXPath.addNamespace("ns", EventingConstants.TOPIC_HEADER_NS);
OMElement topicNode = (OMElement) topicXPath.selectSingleNode(mc.getEnvelope());
if (topicNode != null) {
topic = topicNode.getText();
}
} catch (JaxenException e) {
throw new WSEventException("can not process the xpath ", e);
}
}
return topic;
}
示例8: processDocument
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public OMElement processDocument(InputStream inputStream, String s,
MessageContext messageContext) throws AxisFault {
SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
if (inputStream != null) {
messageContext.setProperty("JSON_STREAM", inputStream);
} else {
EndpointReference endpointReference = messageContext.getTo();
if (endpointReference == null) {
throw new AxisFault("Cannot create DocumentElement without destination EPR");
}
String requestURL;
try {
requestURL = URIEncoderDecoder.decode(endpointReference.getAddress());
} catch (UnsupportedEncodingException e) {
throw AxisFault.makeFault(e);
}
String jsonString;
int index;
//As the message is received through GET, check for "=" sign and consider the second
//half as the incoming JSON message
if ((index = requestURL.indexOf("=")) > 0) {
jsonString = requestURL.substring(index + 1);
messageContext.setProperty("JSON_STRING", jsonString);
} else {
//setting empty json object for no data
messageContext.setProperty("JSON_STRING", "{}");
}
}
return envelope;
}
示例9: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Method invoke
*
* @param msgContext the current MessageContext
* @throws AxisFault
*/
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
// Check for the REST behaviour, if you desire rest beahaviour
// put a <parameter name="doREST" value="true"/> at the axis2.xml
msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext));
msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext));
OutputStream out;
EndpointReference epr = msgContext.getTo();
if (log.isDebugEnabled()) {
log.debug("Sending - " + msgContext.getEnvelope().toString());
}
if (epr != null) {
if (!epr.hasNoneAddress()) {
out = new ByteArrayOutputStream();
TransportUtils.writeMessage(msgContext, out);
finalizeSendWithToAddress(msgContext, (ByteArrayOutputStream)out);
}
} else {
out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
if (out != null) {
TransportUtils.writeMessage(msgContext, out);
} else {
throw new AxisFault(
"Both the TO and Property MessageContext.TRANSPORT_OUT is Null, No where to send");
}
}
TransportUtils.setResponseWritten(msgContext, true);
return InvocationResponse.CONTINUE;
}
示例10: processMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void processMessage(MessageContext inMessageContext,
InputStream in,
OutputStream response) throws AxisFault {
if (this.confContext == null) {
this.confContext = inMessageContext.getConfigurationContext();
}
this.inMessageContext = inMessageContext;
EndpointReference to = inMessageContext.getTo();
String action = inMessageContext.getOptions().getAction();
processMessage(in, to, action, response);
}
示例11: findOperation
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public AxisOperation findOperation(AxisService service, MessageContext messageContext)
throws AxisFault {
AxisService axisService = messageContext.getAxisService();
if (axisService != null && messageContext.getTo() != null) {
String uri = messageContext.getTo().getAddress();
String httpLocation = parseRequestURL(uri, axisService.getName());
String httpMethod = (String) messageContext.getProperty(HTTPConstants.HTTP_METHOD);
if (httpLocation != null) {
httpLocation = httpMethod + httpLocation;
// following code is commented out because it is not allowing us
//to differenciate between httplocation GET /product/ and GET /product
/* if(! httpLocation.endsWith("/")){
httpLocation=httpLocation.concat("/");
}*/
AxisEndpoint axisEndpoint = (AxisEndpoint) messageContext
.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
// Here we check whether the request was dispatched to the correct endpoint. If it
// was we can dispatch the operation using the HTTPLocationDispatcher table of that
// specific endpoint.
if (axisEndpoint != null) {
Map httpLocationTableForResource = (Map) axisEndpoint.getBinding()
.getProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE);
if (httpLocationTableForResource != null) {
return getOperationFromHTTPLocationForResource(httpLocation, httpLocationTableForResource);
}
Map httpLocationTable = (Map) axisEndpoint.getBinding()
.getProperty(WSDL2Constants.HTTP_LOCATION_TABLE);
if (httpLocationTable != null) {
return getOperationFromHTTPLocation(httpLocation, httpLocationTable);
}
}
} else {
log.debug("Attempt to check for Operation using HTTP Location failed");
return null;
}
}
return null;
}
示例12: prepareMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* prepareMessageContext gets a fresh new MessageContext ready to be sent.
* It sets up the necessary properties, transport information, etc.
*
* @param configurationContext the active ConfigurationContext
* @param mc the MessageContext to be configured
* @throws AxisFault if there is a problem
*/
protected void prepareMessageContext(ConfigurationContext configurationContext,
MessageContext mc)
throws AxisFault {
// set options on the message context
if (mc.getSoapAction() == null || "".equals(mc.getSoapAction())) {
mc.setSoapAction(options.getAction());
}
mc.setOptions(new Options(options));
mc.setAxisMessage(axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
// do Target Resolution
TargetResolver targetResolver =
configurationContext.getAxisConfiguration().getTargetResolverChain();
if (targetResolver != null) {
targetResolver.resolveTarget(mc);
}
// if the transport to use for sending is not specified, try to find it
// from the URL
TransportOutDescription senderTransport = options.getTransportOut();
if (senderTransport == null) {
EndpointReference toEPR = (options.getTo() != null) ? options
.getTo() : mc.getTo();
senderTransport = ClientUtils.inferOutTransport(configurationContext
.getAxisConfiguration(), toEPR, mc);
}
mc.setTransportOut(senderTransport);
if (options.getParent() !=null && options.getParent().isManageSession()) {
mc.getOptions().setManageSession(true);
} else if (options.isManageSession()) {
mc.getOptions().setManageSession(true);
}
addReferenceParameters(mc);
}
示例13: setupCorrectTransportOut
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Ensure that if the scheme of the To EPR for the response is different than the
* transport used for the request that the correct TransportOut is available
*/
private static void setupCorrectTransportOut(MessageContext context) throws AxisFault {
// Determine that we have the correct transport available.
TransportOutDescription transportOut = context.getTransportOut();
try {
EndpointReference responseEPR = context.getTo();
if (context.isServerSide() && responseEPR != null) {
if (!responseEPR.hasAnonymousAddress() && !responseEPR.hasNoneAddress()) {
URI uri = new URI(responseEPR.getAddress());
String scheme = uri.getScheme();
if ((transportOut == null) || !transportOut.getName().equals(scheme)) {
ConfigurationContext configurationContext =
context.getConfigurationContext();
transportOut = configurationContext.getAxisConfiguration()
.getTransportOut(scheme);
if (transportOut == null) {
throw new AxisFault("Can not find the transport sender : " + scheme);
}
context.setTransportOut(transportOut);
}
if (context.getOperationContext() != null) {
context.getOperationContext().setProperty(
Constants.DIFFERENT_EPR, Constants.VALUE_TRUE);
}
}
}
} catch (URISyntaxException urise) {
throw AxisFault.makeFault(urise);
}
}
示例14: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Process and SOAP message
*/
public InvocationResponse invoke(MessageContext messageContext) throws AxisFault {
EndpointReference ref = null;
// Get id, type and content
Long id;
Integer type;
// 'soap request' must be called first
if (messageContext.getFLOW() == MessageContext.IN_FLOW) {
// show soap message inside the 'soap request' pane in the applet
id = assignMessageId(messageContext);
type = new Integer(SOAPMonitorConstants.SOAP_MONITOR_REQUEST);
ref = messageContext.getTo();
} else if (messageContext.getFLOW() == MessageContext.OUT_FLOW) {
id = getMessageId(messageContext);
// show soap message inside the 'soap response' pane in the applet
type = new Integer(SOAPMonitorConstants.SOAP_MONITOR_RESPONSE);
ref = messageContext.getFrom();
} else if (messageContext.getFLOW() == MessageContext.IN_FAULT_FLOW) {
id = getMessageId(messageContext);
// show soap message inside the 'soap request' pane in the applet
type = new Integer(SOAPMonitorConstants.SOAP_MONITOR_REQUEST);
ref = messageContext.getFaultTo();
} else if (messageContext.getFLOW() == MessageContext.OUT_FAULT_FLOW) {
id = getMessageId(messageContext);
// show soap message inside the 'soap response' pane in the applet
type = new Integer(SOAPMonitorConstants.SOAP_MONITOR_RESPONSE);
// TODO - How do I get an EPR on MessageContext.OUT_FAULT_FLOW ?
} else {
throw new IllegalStateException("unknown FLOW detected in messageContext: " + messageContext.getFLOW());
}
String target = null;
if (ref != null) {
target = ref.getAddress();
}
// Check for null target
if (target == null) {
target = "";
}
// Get the SOAP portion of the message
String soap = null;
if (messageContext.getEnvelope() != null) {
soap = messageContext.getEnvelope().toString();
}
// If we have an id and a SOAP portion, then send the
// message to the SOAP monitor service
if ((id != null) && (soap != null)) {
SOAPMonitorService.publishMessage(id, type, target, soap);
}
return InvocationResponse.CONTINUE;
}
示例15: WSAHeaderWriter
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public WSAHeaderWriter(MessageContext mc, boolean isSubmissionNamespace, boolean addMU,
boolean replace, boolean includeOptional, String role) {
if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
log.debug("WSAHeaderWriter: isFinal=" + !isSubmissionNamespace + " addMU=" + addMU +
" replace=" + replace + " includeOptional=" + includeOptional+" role="+role);
}
messageContext = mc;
envelope = mc.getEnvelope();
factory = (SOAPFactory)envelope.getOMFactory();
messageContextOptions = messageContext.getOptions();
addressingNamespace =
isSubmissionNamespace ? Submission.WSA_NAMESPACE : Final.WSA_NAMESPACE;
header = envelope.getHeader();
// if there is no soap header in the envelope being processed, add one.
if (header == null) {
header = factory.createSOAPHeader(envelope);
}else{
ArrayList addressingHeaders = header.getHeaderBlocksWithNSURI(addressingNamespace);
if(addressingHeaders!=null && !addressingHeaders.isEmpty()){
existingWSAHeaders = new ArrayList(addressingHeaders.size());
for(Iterator iter=addressingHeaders.iterator();iter.hasNext();){
SOAPHeaderBlock oe = (SOAPHeaderBlock)iter.next();
if(addressingRole == null || addressingRole.length() ==0 || addressingRole.equals(oe.getRole())){
existingWSAHeaders.add(oe.getLocalName());
}
}
}
if(addressingHeaders != null && addressingHeaders.size() ==0){
addressingHeaders = null;
}
}
isFinalAddressingNamespace = !isSubmissionNamespace;
addMustUnderstandAttribute = addMU;
replaceHeaders = replace;
includeOptionalHeaders = includeOptional;
addressingRole = role;
if(!isFinalAddressingNamespace && mc.getTo() == null){
mc.setTo(new EndpointReference(AddressingConstants.Submission.WSA_ANONYMOUS_URL));
}
}