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


Java MessageContext.setFrom方法代码示例

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


在下文中一共展示了MessageContext.setFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMesssageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testMesssageContext() throws AxisFault,
        SOAPProcessingException {
    AxisConfiguration er = new AxisConfiguration();
    AxisService servicesDesc = new AxisService();
    servicesDesc.setName("testService");
    er.addService(servicesDesc);

    ConfigurationContext engineContext = new ConfigurationContext(er);

    MessageContext msgctx = engineContext.createMessageContext();

    SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();

    msgctx.setEnvelope(omFac.getDefaultEnvelope());
    assertNotNull(msgctx.getEnvelope());

    msgctx.setFaultTo(null);
    assertNull(msgctx.getFaultTo());

    msgctx.setFrom(null);
    assertNull(msgctx.getFrom());

    msgctx.setReplyTo(null);
    assertNull(msgctx.getReplyTo());
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:26,代码来源:MessageContextTest.java

示例2: 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

示例3: 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.setFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。