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


Java MessageContext类代码示例

本文整理汇总了Java中org.springframework.ws.context.MessageContext的典型用法代码示例。如果您正苦于以下问题:Java MessageContext类的具体用法?Java MessageContext怎么用?Java MessageContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: handleRequest

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Override
public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {

	TransportContext transportContext = TransportContextHolder.getTransportContext();
	WebServiceConnection webServiceConnection = transportContext.getConnection();
	final String tenant = TenantContextHolder.getContext().getTenant();
	if (webServiceConnection instanceof HeadersAwareSenderWebServiceConnection) {
		if (StringUtils.hasText(tenant)) {
			try {
				((HeadersAwareSenderWebServiceConnection) webServiceConnection).addRequestHeader(getHeaderName(), tenant);
			} catch (IOException e) {
				throw new WebServiceIOException("Error setting header '" + getHeaderName() + "' on connection.", e);
			}
		}
	}
	return true;
}
 
开发者ID:mdeinum,项目名称:spring-multi-tenancy,代码行数:18,代码来源:TentantContextClientInterceptor.java

示例2: handleResponse

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@SuppressWarnings("serial")
@Override
public boolean handleResponse(MessageContext messageContext) {
    String conversationId = null;
    try {
        MessageHeader header = extractMessageHeaderFromMessageContext(messageContext);

        conversationId = header.getConversationId();

    } catch (JAXBException | NullPointerException e) {
        LOG.fatal("Error occurred during retrieving session token", e);
    }

    if (conversationId == null) {
        throw new WebServiceClientException("Couldn't retrieve session token from message") {
        };
    }

    logTokenAndConversationIdFromMessage("", conversationId);

    sessionPool.returnToPool(conversationId);
    return true;
}
 
开发者ID:SabreDevStudio,项目名称:SACS-Java,代码行数:24,代码来源:SessionPoolInterceptor.java

示例3: invoke

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
/**
 * Invoked by Spring-WS when a {@link WebServiceMessage} is received
 */
public void invoke(MessageContext messageContext) throws Exception {
    Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOptionalOut);
    populateExchangeFromMessageContext(messageContext, exchange);

    // start message processing
    getProcessor().process(exchange);

    if (exchange.getException() != null) {
        throw exchange.getException();
    } else if (exchange.getPattern().isOutCapable()) {
        Message responseMessage = exchange.getOut(Message.class);
        if (responseMessage != null) {
            Source responseBody = responseMessage.getBody(Source.class);
            WebServiceMessage response = messageContext.getResponse();

            configuration.getMessageFilter().filterConsumer(exchange, response);

            XmlConverter xmlConverter = configuration.getXmlConverter();
            xmlConverter.toResult(responseBody, response.getPayloadResult());
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:SpringWebserviceConsumer.java

示例4: getEndpointInternal

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Override
protected Object getEndpointInternal(MessageContext messageCtx) throws Exception {
  SOAPMessage message = SOAPUtil.extractSoapMessage(messageCtx.getRequest());
  if (message.getSOAPHeader() != null) {
    AbstractXTeeBaseEndpoint endpoint = methodMap.get(getRequestMethod(message.getSOAPHeader()));
    if (endpoint != null) {
      if (log.isDebugEnabled()) {
        log.debug("Matched " + endpoint + " to " + endpoint.getClass().getSimpleName());
      }
      return endpoint;
    }
  }

  try {
    if (SOAPUtil.getNodeByXPath(message.getSOAPBody(), "/*/*/*[local-name()='listMethods']") != null) {
      log.debug("Matched headerless listMethods request.");
      return getApplicationContext().getBean(getApplicationContext().getBeanNamesForType(ListMethodsEndpoint.class)[0]);
    }
  } catch (NullPointerException e) {
    // ListMethods lookup failed
  }
  return null;
}
 
开发者ID:nortal,项目名称:j-road,代码行数:24,代码来源:XTeeEndpointMapping.java

示例5: logMessage

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
private boolean logMessage(MessageContext mc, MessageType messageType) {
  if (log.isDebugEnabled()) {
    WebServiceMessage message = MessageType.REQUEST.equals(messageType) ? mc.getRequest() : mc.getResponse();

    if (message instanceof SaajSoapMessage) {
      OutputStream out = new ByteArrayOutputStream();
      try {
        ((SaajSoapMessage) message).writeTo(out);
        log.debug(messageType + " message follows:\n" + out.toString());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }

  return true;
}
 
开发者ID:nortal,项目名称:j-road,代码行数:18,代码来源:WSConsumptionLoggingInterceptor.java

示例6: handleRequest

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
        throws IOException, SAXException, TransformerException {

    // validate payload
    boolean reqValResult = super.handleRequest(messageContext, endpoint);

    // validate header
    if (reqValResult && validateHeader && !ignoreRequest(messageContext)) {
        SaajSoapMessage soapMessage = (SaajSoapMessage) messageContext.getRequest();
        SoapHeader soapHeader = soapMessage.getSoapHeader();

        ValidationIntegrationException[] errors = validateHeader(soapHeader);
        if (!ObjectUtils.isEmpty(errors)) {
            return handleHeaderValidationErrors(messageContext, errors);
        } else if (logger.isDebugEnabled()) {
            logger.debug("Request header validated");
        }
    }

    return reqValResult;
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:23,代码来源:HeaderAndPayloadValidatingInterceptor.java

示例7: resolveExceptionInternal

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Override
protected final boolean resolveExceptionInternal(MessageContext messageContext, Object endpoint, Exception ex) {
    Assert.isInstanceOf(SoapMessage.class, messageContext.getResponse(),
            "SimpleSoapExceptionResolver requires a SoapMessage");

    if (throttlingAsServerError && ex instanceof ThrottlingExceededException) {
        // no SOAP fault => server error
        return false;
    } else {
        SoapMessage response = (SoapMessage) messageContext.getResponse();
        String faultString = StringUtils.hasLength(ex.getMessage()) ? ex.getMessage() : ex.toString();
        SoapBody body = response.getSoapBody();
        SoapFault fault = body.addServerOrReceiverFault(faultString, getLocale());
        customizeFault(messageContext, endpoint, ex, fault);

        return true;
    }
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:19,代码来源:ErrorCodeAwareSoapExceptionResolver.java

示例8: handleInvalidXmlException

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Override
protected void handleInvalidXmlException(HttpServletRequest req, HttpServletResponse res, Object handler,
                                         InvalidXmlException ex) throws Exception {

    WebServiceConnection connection = new MyHttpServletConnection(req, res);

    TransportContext previousTransportContext = TransportContextHolder.getTransportContext();
    TransportContextHolder.setTransportContext(new DefaultTransportContext(connection));

    try {
        MessageContext messageContext = new DefaultMessageContext(getMessageFactory().createWebServiceMessage(),
                getMessageFactory());

        SoapBody soapBody = ((SoapMessage) messageContext.getResponse()).getSoapBody();
        soapBody.addServerOrReceiverFault(getFaultString(ex), Locale.ENGLISH);
        connection.send(messageContext.getResponse());
    } finally {
        TransportUtils.closeConnection(connection);
        TransportContextHolder.setTransportContext(previousTransportContext);
    }
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:22,代码来源:ErrorAwareWebServiceMessageReceiverHandlerAdapter.java

示例9: handleValidationException

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Override //Overridden in order to be able to set the level of logging
protected boolean handleValidationException(WsSecurityValidationException ex, MessageContext messageContext) {
    logFault.log(ex);

    if (this.exceptionResolver != null) {
        this.exceptionResolver.resolveException(messageContext, (Object) null, ex);
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("No exception resolver present, creating basic soap fault");
        }

        SoapBody response = ((SoapMessage) messageContext.getResponse()).getSoapBody();
        response.addClientOrSenderFault(ex.getMessage(), Locale.ENGLISH);
    }

    return false;
}
 
开发者ID:digipost,项目名称:sdp-shared,代码行数:18,代码来源:Wss4jInterceptor.java

示例10: initializeRequestData

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
/**
 * Creates and initializes a request data for the given message context.
 *
 * @param messageContext the message context
 * @return the request data
 */
protected RequestData initializeRequestData(final MessageContext messageContext) {
    RequestData requestData = new RequestData();
    requestData.setMsgContext(messageContext);

    // reads securementUsername first from the context then from the property
    String contextUsername = (String) messageContext.getProperty(SECUREMENT_USER_PROPERTY_NAME);
    if (StringUtils.hasLength(contextUsername)) {
        requestData.setUsername(contextUsername);
    } else {
        requestData.setUsername(securementUsername);
    }
    requestData.setAppendSignatureAfterTimestamp(true);
    requestData.setTimeStampTTL(securementTimeToLive);

    requestData.setWssConfig(wssConfig);
    return requestData;
}
 
开发者ID:digipost,项目名称:sdp-shared,代码行数:24,代码来源:Wss4jInterceptor.java

示例11: doSendAndReceive

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Override
protected <T> T doSendAndReceive(final MessageContext messageContext, final WebServiceConnection connection,
                                 final WebServiceMessageCallback requestCallback, final WebServiceMessageExtractor<T> responseExtractor) throws IOException {
    EbmsContext ebmsContext = EbmsContext.from(messageContext);
    ebmsContext.remoteParty = Optional.of(ebmsAktoerRemoteParty.orgnr);
    if (requestCallback instanceof EbmsContextAware) {
        ((EbmsContextAware) requestCallback).setContext(ebmsContext);
    }
    if (responseExtractor instanceof EbmsContextAware) {
        ((EbmsContextAware) responseExtractor).setContext(ebmsContext);
    }
    try {
        return super.doSendAndReceive(messageContext, connection, requestCallback, responseExtractor);
    } catch (IOException e) {
        throw new MessageSenderIOException(e.getMessage(), e);
    }
}
 
开发者ID:digipost,项目名称:sdp-shared,代码行数:18,代码来源:EbmsContextAwareWebServiceTemplate.java

示例12: handleRequest

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Override
public boolean handleRequest(MessageContext messageContext)
		throws WebServiceClientException {
	WebServiceMessage request = messageContext.getRequest();
	if(request instanceof SoapMessage) {
		SoapMessage soapMessage = (SoapMessage) request;
		SoapEnvelope envelope = soapMessage.getEnvelope();
		SoapHeader header = envelope.getHeader();
		RequestServerVersion rsv = new RequestServerVersion();

		try {
			Marshaller m = jaxbContext.createMarshaller();
			m.marshal(rsv, header.getResult());
		} catch (JAXBException e) {
			log.error("JAXBException raised while attempting to add RequestServerVersion to soap header " + rsv, e);
			throw new ExchangeWebServicesRuntimeException("JAXBException raised while attempting to add RequestServerVersion to soap header " + rsv, e);
		}
	}
	return true;
}
 
开发者ID:Bedework,项目名称:exchange-ws-client,代码行数:21,代码来源:RequestServerVersionClientInterceptor.java

示例13: shouldInvoke

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
private boolean shouldInvoke(MessageContext messageContext) throws Exception {
	List<EndpointMapping> endpointMappings = messageDispatcher.getEndpointMappings();
	// There should be only one endpoint mapped in the module: check it
	Assert.isTrue(endpointMappings != null && endpointMappings.size() == 1);

	EndpointMapping endpointMapping = endpointMappings.iterator().next();
	for (EndpointInterceptor endpointInterceptor : endpointMapping.getEndpoint(messageContext).getInterceptors()) {
		// Check to see if the interceptor is directly an instance of a service specific interceptor.
		// If so, we don't have to fall back to our default delegate
		if (endpointInterceptor instanceof ServiceSpecificEndpointInterceptor) {
			return false;
		}

		// Check to see if the interceptor is decorated by DelegatingSmartEndpointInterceptor
		// Unfortunately there is no standard API way of detecting this, so we need some reflection.
		// If so, check that the decorated instance is instance of a service specific interceptor.
		// If so, we don't have to fall back to our default delegate
		if (endpointInterceptor instanceof DelegatingSmartEndpointInterceptor) {
			if (FieldUtils.readField(endpointInterceptor, "delegate", true) instanceof ServiceSpecificEndpointInterceptor) {
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:koen-serneels,项目名称:ws-proxy,代码行数:26,代码来源:DefaultInterceptorExecutor.java

示例14: handleResponse

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
/**
 * Processes response using interceptors.
 * @param messageContext
 * @throws IOException
 */
protected void handleResponse(MessageContext messageContext) throws IOException {
	if (!interceptors.isEmpty())
	{
		boolean hasFault = hasFault(messageContext);
		for (EndpointInterceptor interceptor:interceptors)
		{
			try {
				if (!hasFault)
				{
					if (!interceptor.handleResponse(messageContext, null)) return;
				}
				else
				{
					if (!interceptor.handleFault(messageContext, null)) return;
				}
			} catch (Exception e) {
				throw new IOException("Unexpected exception",e);
			}
		}
	}
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:27,代码来源:MockWebServiceConnection.java

示例15: testSendMessageAndCompareResponseFail

import org.springframework.ws.context.MessageContext; //导入依赖的package包/类
@Test
public void testSendMessageAndCompareResponseFail() throws Exception
{
	MessageContext message = wsTestHelper.receiveMessage("xml/valid-message.xml");
	assertNotNull(message);
	assertNotNull(message.getResponse().getPayloadSource());
	
	try
	{
		wsTestHelper.createMessageValidator(message.getResponse()).compare("mock-responses/test/different-response.xml");
		fail("Exception expected");
	}
	catch(WsTestException e)
	{
		//ok
	}
}
 
开发者ID:lukas-krecan,项目名称:spring-ws-test,代码行数:18,代码来源:DefaultWsTestHelperTest.java


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