当前位置: 首页>>代码示例>>Java>>正文


Java MessageContext.setIncomingTransportName方法代码示例

本文整理汇总了Java中org.apache.axis2.context.MessageContext.setIncomingTransportName方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setIncomingTransportName方法的具体用法?Java MessageContext.setIncomingTransportName怎么用?Java MessageContext.setIncomingTransportName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axis2.context.MessageContext的用法示例。


在下文中一共展示了MessageContext.setIncomingTransportName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:27,代码来源:AbstractTransportListener.java

示例2: buildMessaage

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public MessageContext buildMessaage(SMSMessage msg,ConfigurationContext configurationContext)
        throws InvalidMessageFormatException {
    String message = msg.getContent();
    String sender =  msg.getSender();
    String receiver = msg.getReceiver();
    String[] parts = message.split(":");


    //may be can add feature to send message format for a request like ????
    if (parts.length < 2) {
        throw new InvalidMessageFormatException("format must be  \"service_name \" : \"opration_name\" : " +
                "\"parm_1=val_1\" :..:\"param_n = val_n\"");
    } else {
        AxisConfiguration repo = configurationContext.getAxisConfiguration();
        MessageContext messageContext = configurationContext.createMessageContext();

        parts = trimSplited(parts);

        try {
            AxisService axisService = repo.getService(parts[0]);
            if (axisService == null) {

                throw new InvalidMessageFormatException("Service : " + parts[0] + "does not exsist");

            } else {
                messageContext.setAxisService(axisService);
                AxisOperation axisOperation = axisService.getOperation(new QName(parts[1]));

                if (axisOperation == null) {
                    throw new InvalidMessageFormatException("Operation: " + parts[1] + " does not exsist");
                }

                messageContext.setAxisOperation(axisOperation);

                messageContext.setAxisMessage(axisOperation.getMessage(
                        WSDLConstants.MESSAGE_LABEL_IN_VALUE));

                Map params = getParams(parts,2);

                SOAPEnvelope soapEnvelope = createSoapEnvelope(messageContext , params);
                messageContext.setServerSide(true);
                messageContext.setEnvelope(soapEnvelope);
                TransportInDescription in = configurationContext.getAxisConfiguration().getTransportIn("sms");
                TransportOutDescription out = configurationContext.getAxisConfiguration().getTransportOut("sms");
                messageContext.setIncomingTransportName("sms");
                messageContext.setProperty(SMSTransportConstents.SEND_TO , sender);
                messageContext.setProperty(SMSTransportConstents.DESTINATION , receiver);
                messageContext.setTransportIn(in);
                messageContext.setTransportOut(out);
                handleSMSProperties(msg , messageContext);
                return messageContext;
            }


        } catch (AxisFault axisFault) {
            log.debug("[DefaultSMSMessageBuilderImpl] Error while extracting the axis2Service \n" +
                    axisFault);
        }

    }


    return null;
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:65,代码来源:DefaultSMSMessageBuilderImpl.java

示例3: createMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Creates message context using values received in XMPP packet
 * @param packet
 * @return MessageContext
 * @throws AxisFault
 */
private MessageContext createMessageContext(Packet packet) throws AxisFault {
	Message message = (Message) packet;		

	Boolean isServerSide = (Boolean) message
			.getProperty(XMPPConstants.IS_SERVER_SIDE);
	String serviceName = (String) message
			.getProperty(XMPPConstants.SERVICE_NAME);
	String action = (String) message.getProperty(XMPPConstants.ACTION);
	MessageContext msgContext = null;

	TransportInDescription transportIn = configurationContext
			.getAxisConfiguration().getTransportIn("xmpp");
	TransportOutDescription transportOut = configurationContext
			.getAxisConfiguration().getTransportOut("xmpp");
	if ((transportIn != null) && (transportOut != null)) {
		msgContext = configurationContext.createMessageContext();
		msgContext.setTransportIn(transportIn);
		msgContext.setTransportOut(transportOut);
		if (isServerSide != null) {
			msgContext.setServerSide(isServerSide.booleanValue());
		}
		msgContext.setProperty(
				CONTENT_TYPE,
				"text/xml");
		msgContext.setProperty(
				Constants.Configuration.CHARACTER_SET_ENCODING, "UTF-8");
		msgContext.setIncomingTransportName("xmpp");

		Map services = configurationContext.getAxisConfiguration()
				.getServices();

		AxisService axisService = (AxisService) services.get(serviceName);
		msgContext.setAxisService(axisService);
		msgContext.setSoapAction(action);

		// pass the configurationFactory to transport sender
		msgContext.setProperty("XMPPConfigurationFactory",
				this.xmppConnectionFactory);

		if (packet.getFrom() != null) {
			msgContext.setFrom(new EndpointReference(packet.getFrom()));
		}
		if (packet.getTo() != null) {
			msgContext.setTo(new EndpointReference(packet.getTo()));
		}

		XMPPOutTransportInfo xmppOutTransportInfo = new XMPPOutTransportInfo();
		xmppOutTransportInfo
				.setConnectionFactory(this.xmppConnectionFactory);

		String packetFrom = packet.getFrom();
		if (packetFrom != null) {
			EndpointReference fromEPR = new EndpointReference(packetFrom);
			xmppOutTransportInfo.setFrom(fromEPR);
			xmppOutTransportInfo.setDestinationAccount(packetFrom);
		}

		// Save Message-Id to set as In-Reply-To on reply
		String xmppMessageId = packet.getPacketID();
		if (xmppMessageId != null) {
			xmppOutTransportInfo.setInReplyTo(xmppMessageId);
		}
		xmppOutTransportInfo.setSequenceID((String)message.getProperty(XMPPConstants.SEQUENCE_ID));
		msgContext.setProperty(
				org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
				xmppOutTransportInfo);
		buildSOAPEnvelope(packet, msgContext);
	} else {
		throw new AxisFault("Either transport in or transport out is null");
	}
	return msgContext;
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:79,代码来源:XMPPPacketListener.java

示例4: handleResponse

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
   * Retrieves the properties from the proxyOutMessageContext and sets the values to the
   * inMessageContext.
   *
   * @param proxyOutMessageContext the active message context
   * @param initialMessageContext  the initial message context, which was stored as a property
   *                               in the proxyOutMessageContext
   * @throws AxisFault AxisFault
   */
  private void handleResponse(MessageContext proxyOutMessageContext, MessageContext initialMessageContext) throws AxisFault {
      MessageContext inMessageContext = initialMessageContext.getOperationContext().
              getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);

      // setting the properties
Iterator<String> initialPropertyIterator = proxyOutMessageContext.getPropertyNames();
if (initialPropertyIterator != null) {
	while (initialPropertyIterator.hasNext()) {
		String strKey = initialPropertyIterator.next();
		Object paramObj = proxyOutMessageContext.getProperty(strKey);
		if (paramObj != null) {
			inMessageContext.setProperty(strKey, paramObj);
		}
	}
} 

      inMessageContext.setEnvelope(getEnvelope(proxyOutMessageContext));
      inMessageContext.setAxisServiceGroup(initialMessageContext.getAxisServiceGroup());
      inMessageContext.setAxisService(initialMessageContext.getAxisService());
      inMessageContext.setAxisOperation(initialMessageContext.getAxisOperation());
      inMessageContext.setAxisMessage(initialMessageContext.getAxisOperation().getMessage(
              WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
      inMessageContext.setIncomingTransportName(Constants.TRANSPORT_LOCAL);
      inMessageContext.setServiceContext(initialMessageContext.getServiceContext());

      // set properties on response
      inMessageContext.setServerSide(true);
      inMessageContext.setProperty(MessageContext.TRANSPORT_OUT,
              initialMessageContext.getProperty(MessageContext.TRANSPORT_OUT));
      inMessageContext.setProperty(Constants.OUT_TRANSPORT_INFO,
              initialMessageContext.getProperty(Constants.OUT_TRANSPORT_INFO));
      inMessageContext.setTransportIn(initialMessageContext.getTransportIn());
      inMessageContext.setTransportOut(initialMessageContext.getTransportOut());

      if (log.isDebugEnabled()) {
          log.debug("Setting AxisServiceGroup - " + initialMessageContext.getAxisServiceGroup());
          log.debug("Setting AxisService - " + initialMessageContext.getAxisService());
          log.debug("Setting AxisOperation - " + initialMessageContext.getAxisOperation());
          log.debug("Setting AxisMessage - " + initialMessageContext.getAxisOperation().
                  getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
          log.debug("Setting Incoming Transport name - " + Constants.TRANSPORT_LOCAL);
          log.debug("Setting Service Context " + initialMessageContext.getServiceGroupContext().toString());

          log.debug("Setting ServerSide to true");
          log.debug("Setting " + MessageContext.TRANSPORT_OUT + " property to " +
                  initialMessageContext.getProperty(MessageContext.TRANSPORT_OUT));
          log.debug("Setting " + Constants.OUT_TRANSPORT_INFO + " property to " +
                  initialMessageContext.getProperty(Constants.OUT_TRANSPORT_INFO));
          log.debug("Setting TransportIn - " + initialMessageContext.getTransportIn());
          log.debug("Setting TransportOut - " + initialMessageContext.getTransportOut());

          log.debug("Setting ReplyTo - " + initialMessageContext.getReplyTo());
          log.debug("Setting FaultTo - " + initialMessageContext.getFaultTo());
      }

      // copy the message type property that is used by the out message to the response message
      inMessageContext.setProperty(Constants.Configuration.MESSAGE_TYPE,
              initialMessageContext.getProperty(Constants.Configuration.MESSAGE_TYPE));

      if (initialMessageContext.getMessageID() != null) {
          inMessageContext.setRelationships(
                  new RelatesTo[]{new RelatesTo(initialMessageContext.getMessageID())});
      }

      inMessageContext.setReplyTo(initialMessageContext.getReplyTo());
      inMessageContext.setFaultTo(initialMessageContext.getFaultTo());

      AxisEngine.receive(inMessageContext);
  }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:79,代码来源:LocalResponder.java

示例5: createMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * @param request
 * @param response
 * @param invocationType : If invocationType=true; then this will be used in SOAP message
 *                       invocation. If invocationType=false; then this will be used in REST message invocation.
 * @return MessageContext
 * @throws IOException
 */
protected MessageContext createMessageContext(HttpServletRequest request,
                                              HttpServletResponse response,
                                              boolean invocationType) throws IOException {
    MessageContext msgContext = configContext.createMessageContext();
    String requestURI = request.getRequestURI();

    String trsPrefix = request.getRequestURL().toString();
    int sepindex = trsPrefix.indexOf(':');
    if (sepindex > -1) {
        trsPrefix = trsPrefix.substring(0, sepindex);
        msgContext.setIncomingTransportName(trsPrefix);
    } else {
        msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
        trsPrefix = Constants.TRANSPORT_HTTP;
    }
    TransportInDescription transportIn =
            axisConfiguration.getTransportIn(msgContext.getIncomingTransportName());
    //set the default output description. This will be http

    TransportOutDescription transportOut = axisConfiguration.getTransportOut(trsPrefix);
    if (transportOut == null) {
        // if the req coming via https but we do not have a https sender
        transportOut = axisConfiguration.getTransportOut(Constants.TRANSPORT_HTTP);
    }


    msgContext.setTransportIn(transportIn);
    msgContext.setTransportOut(transportOut);
    msgContext.setServerSide(true);

    if (!invocationType) {
        String query = request.getQueryString();
        if (query != null) {
            requestURI = requestURI + "?" + query;
        }
    }

    msgContext.setTo(new EndpointReference(requestURI));
    msgContext.setFrom(new EndpointReference(request.getRemoteAddr()));
    msgContext.setProperty(MessageContext.REMOTE_ADDR, request.getRemoteAddr());
    msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
            new ServletBasedOutTransportInfo(response));
    // set the transport Headers
    msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, getTransportHeaders(request));
    msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, request);
    msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, response);
    try {
        ServletContext context = getServletContext();
        if(context != null) {
            msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT, context);
        }
    } catch (Exception e){
        log.debug(e.getMessage(), e);
    }

    //setting the RequestResponseTransport object
    msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
            new ServletRequestResponseTransport());

    return msgContext;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:70,代码来源:AxisServlet.java


注:本文中的org.apache.axis2.context.MessageContext.setIncomingTransportName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。