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


Java LogicalMessageContext类代码示例

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


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

示例1: handleMessage

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
/**
   * Handle message 
   * @param smc SOAPMessageContext
   * @return boolean 
   */
public boolean handleMessage(LogicalMessageContext smc) {
	Boolean outboundProperty = (Boolean) smc
			.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); 
	if (outboundProperty.booleanValue()) { 
		startTime = new Date();
		smc.put(HandlerName + "StartTime", startTime);
	} else { 
		try {
			startTime = (Date) smc.get(HandlerName + "StartTime");
			endTime = new Date();
			long elapsedTime = endTime.getTime() - startTime.getTime();
			
			smc.put("ELAPSED_TIME", elapsedTime);
			smc.setScope("ELAPSED_TIME", MessageContext.Scope.APPLICATION); 
			logger.info("Elapsed time in handler " + HandlerName + " is "
					+ elapsedTime); 
		} catch (Exception x) {
			x.printStackTrace();
		}
	} 
	return true;
}
 
开发者ID:Appverse,项目名称:appverse-server,代码行数:28,代码来源:ClientPerformanceMonitorLogicalHandler.java

示例2: doLog

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
private void doLog(LogicalMessageContext smc) {
if (!(Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
    try {
	TransformerFactory tff = TransformerFactory.newInstance();
	Transformer tf = tff.newTransformer();
	tf.setOutputProperty(OutputKeys.INDENT, "yes");
	tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
	
	Source sc = smc.getMessage().getPayload();
	
	StreamResult result = new StreamResult(outputStream);
	tf.transform(sc, result);
	
    } catch (Exception e) {
	PrintWriter ps = new PrintWriter(outputStream);
	ps.println("Exception getting response message log: ");
	e.printStackTrace(ps);
    }
}
   }
 
开发者ID:chtiJBUG,项目名称:wise-webui,代码行数:21,代码来源:ResponseLogHandler.java

示例3: testGetMultiplePayloadsAsSource

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
/**
 * Test to make sure we can get the payload multiple times from the same LogicalMessage.
 * @throws Exception
 */
public void testGetMultiplePayloadsAsSource() throws Exception {
    LogicalMessageContext lmc = createSampleContext();

    LogicalMessage msg = lmc.getMessage();
    assertTrue("The returned LogicalMessage was null", msg != null);

    int loopCount = 3;
    for (int i = 0; i < loopCount; ++i) {
        Source payload = msg.getPayload();
        assertTrue("Attempt number "  + i + " to get the payload (Source) was null", payload != null);


        String resultContent = _getStringFromSource(payload);
        assertTrue("The content returned in loop " + i + " was null", resultContent != null);
        assertTrue("The content returned in loop " + i + " was incomplete, unexpected element", resultContent.indexOf("echoString") > -1);
        assertTrue("The content returned in loop " + i + " was incomplete, unexpected content", resultContent.indexOf(INPUT) > -1);            
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:LogicalMessageContextTests.java

示例4: testConvertMessageToFault

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
public void testConvertMessageToFault() throws Exception {
    LogicalMessageContext lmc = createSampleContext();
 
    LogicalMessage msg = lmc.getMessage();
    assertTrue("The returned LogicalMessage was null", msg != null);

    Source payload = msg.getPayload();
    assertTrue("The returned payload (Source) was null", payload != null);

    String resultContent = _getStringFromSource(payload);
    assertTrue("The content returned was null", resultContent != null);
    
    ByteArrayInputStream bais = new ByteArrayInputStream(sampleSOAP11FaultPayload.getBytes());
    StreamSource faultSource = new StreamSource(bais);
    
    msg.setPayload(faultSource);
    
    Source newFaultSource = msg.getPayload();
    assertTrue("The new fault content returned was null", faultSource != null);
    
    String newFaultContent = _getStringFromSource(newFaultSource);
    assertTrue("The new fault content returned was invalid", newFaultContent.equals(sampleSOAP11FaultPayload));
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:LogicalMessageContextTests.java

示例5: createSampleFaultContext

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
private LogicalMessageContext createSampleFaultContext() throws Exception {
    MessageFactory factory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
    Message msg = factory.create(Protocol.soap11);
    
    XMLFaultReason reason = new XMLFaultReason(FAULT_INPUT);        
    XMLFault fault = new XMLFault(XMLFaultCode.SENDER, reason);
    msg.setXMLFault(fault);
    
    MessageContext mc = new MessageContext();
    mc.setMEPContext(new MEPContext(mc));
    mc.setMessage(msg);
    
    LogicalMessageContext lmc = MessageContextFactory.createLogicalMessageContext(mc);
    
    return lmc;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:LogicalMessageContextTests.java

示例6: testInboundFaultFlow

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
/**
 * A test that mimics the inbound flow through a handler chain.
 */
public void testInboundFaultFlow() throws Exception {
    MessageContext mc = createSampleFaultMessageContext();
    
    LogicalMessageContext lmc = MessageContextFactory.createLogicalMessageContext(mc);
    LogicalMessage lm = lmc.getMessage();
    Source payload = lm.getPayload();
    assertTrue("The returned payload (Source) was null", payload != null);
    
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    StreamResult result = new StreamResult(baos);
    Transformer t = TransformerFactory.newInstance().newTransformer();
    t.transform(payload, result);
    
    String content = new String(baos.toByteArray());
    assertTrue("The returned content (String) from the payload was null", content != null);
    assertTrue("The <faultcode> element was not found", content.indexOf("faultcode") > -1);
    assertTrue("The <faultstring> element was not found", content.indexOf("faultstring") > -1);
    assertTrue("The fault did not contain the expected fault string", content.indexOf(FAULT_INPUT) > -1);
            
    SoapMessageContext smc = MessageContextFactory.createSoapMessageContext(mc);
    SOAPMessage sm = smc.getMessage();
    assertTrue("The returned SOAPMessage was null", sm != null);
    assertTrue("The SOAPMessage did not contain a SOAPBody", sm.getSOAPBody() != null);
    assertTrue("The SOAPBody did not contain a SOAPFault", sm.getSOAPBody().getFault() != null);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:29,代码来源:CompositeMessageContextTests.java

示例7: testOutboundFaultFlow

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
/**
 * A test that mimics the outbound flow through a handler chain.
 */
public void testOutboundFaultFlow() throws Exception {
    MessageContext mc = createSampleFaultMessageContext();
    
    SoapMessageContext smc = MessageContextFactory.createSoapMessageContext(mc);
    SOAPMessage sm = smc.getMessage();
    assertTrue("The returned SOAPMessage was null", sm != null);
    assertTrue("The SOAPMessage did not contain a SOAPBody", sm.getSOAPBody() != null);
    assertTrue("The SOAPBody did not contain a SOAPFault", sm.getSOAPBody().getFault() != null);
    
    LogicalMessageContext lmc = MessageContextFactory.createLogicalMessageContext(mc);
    LogicalMessage lm = lmc.getMessage();
    Source payload = lm.getPayload();
    assertTrue("The returned payload (Source) was null", payload != null);
    
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    StreamResult result = new StreamResult(baos);
    Transformer t = TransformerFactory.newInstance().newTransformer();
    t.transform(payload, result);
    
    String content = new String(baos.toByteArray());
    assertTrue("The returned content (String) from the payload was null", content != null);
    assertTrue("The <faultcode> element was not found", content.indexOf("faultcode") > -1);
    assertTrue("The <faultstring> element was not found", content.indexOf("faultstring") > -1);
    assertTrue("The fault did not contain the expected fault string", content.indexOf(FAULT_INPUT) > -1);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:29,代码来源:CompositeMessageContextTests.java

示例8: handleMessage

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
@Override
public boolean handleMessage(LogicalMessageContext context)
{
   Boolean isOutbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
   String operation = ((QName) context.get(MessageContext.WSDL_OPERATION)).getLocalPart();
   if (!isOutbound && !operation.startsWith("getHandlerCounter")) {
      counter.incrementAndGet();
   } else if (isOutbound && !operation.startsWith("getHandlerCounter")) {
      outboundCounter.incrementAndGet();
   }
   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:13,代码来源:LogicalSimpleHandler.java

示例9: handleFault

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
@Override
public boolean handleFault(LogicalMessageContext context)
{
   String operation = ((QName) context.get(MessageContext.WSDL_OPERATION)).getLocalPart();
   if (!operation.startsWith("getHandlerCounter")) {
      outboundCounter.incrementAndGet();
   }
   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:10,代码来源:LogicalSimpleHandler.java

示例10: appendHandlerName

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
private boolean appendHandlerName(MessageContext msgContext, String direction)
{
   try
   {
      // Get the payload as Source
      LogicalMessageContext logicalContext = (LogicalMessageContext)msgContext;
      Source source = logicalContext.getMessage().getPayload();
      TransformerFactory tf = TransformerFactory.newInstance();
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      tf.newTransformer().transform(source, new StreamResult(baos));

      // Parse the payload and extract the value
      Element root = DOMUtils.parse(new ByteArrayInputStream(baos.toByteArray()), getDocumentBuilder());
      Element element = DOMUtils.getFirstChildElement(root);

      String oldValue = DOMUtils.getTextContent(element);
      String newValue = oldValue + ":" + direction + ":LogicalSourceHandler";
      element.setTextContent(newValue);

      log.debug("oldValue: " + oldValue);
      log.debug("newValue: " + newValue);

      // Set the updated payload
      source = new DOMSource(root);
      logicalContext.getMessage().setPayload(source);

      return true;
   }
   catch (RuntimeException rte)
   {
      throw rte;
   }
   catch (Exception ex)
   {
      throw new WebServiceException(ex);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:38,代码来源:LogicalSourceHandler.java

示例11: appendHandlerName

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
public boolean appendHandlerName(MessageContext msgContext, String direction)
{
   try
   {
      // Get the payload as Source
      LogicalMessageContext logicalContext = (LogicalMessageContext)msgContext;
      Source source = logicalContext.getMessage().getPayload();
      TransformerFactory tf = TransformerFactory.newInstance();
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      tf.newTransformer().transform(source, new StreamResult(baos));

      // Parse the payload and extract the value
      Element root = DOMUtils.parse(new ByteArrayInputStream(baos.toByteArray()), getDocumentBuilder());

      String oldValue = DOMUtils.getTextContent(root);
      String newValue = oldValue + ":" + direction + ":LogicalSourceHandler";
      root.setTextContent(newValue);

      log.debug("oldValue: " + oldValue);
      log.debug("newValue: " + newValue);

      // Set the updated payload
      source = new DOMSource(root);
      logicalContext.getMessage().setPayload(source);

      return true;
   }
   catch (RuntimeException rte)
   {
      throw rte;
   }
   catch (Exception ex)
   {
      throw new WebServiceException(ex);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:37,代码来源:LogicalSourceHandler.java

示例12: appendHandlerName

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
public boolean appendHandlerName(MessageContext msgContext, String direction)
{
   try
   {
      // Get the payload as Source
      LogicalMessageContext logicalContext = (LogicalMessageContext)msgContext;
      Source source = logicalContext.getMessage().getPayload();
      TransformerFactory tf = TransformerFactory.newInstance();
      ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
      tf.newTransformer().transform(source, new StreamResult(baos));

      // Parse the payload and extract the value
      Element root = DOMUtils.parse(new ByteArrayInputStream(baos.toByteArray()), getDocumentBuilder());

      String oldValue = DOMUtils.getTextContent(root);
      String newValue = oldValue + ":" + direction + "LogicalHandler";
      root.setTextContent(newValue);

      log.debug("oldValue: " + oldValue);
      log.debug("newValue: " + newValue);

      // Set the updated payload
      source = new DOMSource(root);
      logicalContext.getMessage().setPayload(source);

      return true;
   }
   catch (RuntimeException rte)
   {
      throw rte;
   }
   catch (Exception ex)
   {
      throw new WebServiceException(ex);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:37,代码来源:LogicalSourceHandler.java

示例13: invokeLogicalHandlersHandleFault

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
@Override
public boolean invokeLogicalHandlersHandleFault(boolean requestor, LogicalMessageContext context)
{
   if (context.containsKey(KEY)) {
      return true;
   }
   return super.invokeLogicalHandlersHandleFault(requestor, context);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:9,代码来源:HandlerAuthInterceptor.java

示例14: storePayload

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
private void storePayload(LogicalMessageContext context) {
	Boolean outboundProperty = (Boolean) context
			.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
	if (outboundProperty) {
		return;
	}
	LogicalMessage logicalMessage = context.getMessage();
	Source payloadSource = logicalMessage.getPayload();
	this.payload = toString(payloadSource);
}
 
开发者ID:e-Contract,项目名称:mycarenet,代码行数:11,代码来源:PayloadLogicalHandler.java

示例15: handleMessage

import javax.xml.ws.handler.LogicalMessageContext; //导入依赖的package包/类
@Override
   public boolean handleMessage(LogicalMessageContext messageContext) {
boolean outbound = (Boolean) messageContext
	.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
LogicalMessage message = messageContext.getMessage();

if (outbound) {
    Source payload = message.getPayload();
    Result result = new RequestTransformer().transform(payload);
    if (!(result instanceof StreamResult)) {
	LOGGER.error(
		"Expected javax.xml.transform.stream.StreamSource but got {}.",
		result.getClass().getName());
	throw new WebServiceException(
		"Expected javax.xml.transform.stream.StreamSource but got "
			+ result.getClass().getName());
    }
    String xml = ((StreamResult) result).getWriter().toString();
    try {
	message.setPayload(new StreamSource(new ByteArrayInputStream(
		xml.getBytes("UTF-8"))));
    } catch (UnsupportedEncodingException e) {
	LOGGER.error(
		"How the heck did this happen? UTF-8 is available in all JVMs",
		e);
	throw new WebServiceException(
		"How the heck did this happen? UTF-8 is available in all JVMs",
		e);
    }
}
return true;
   }
 
开发者ID:asarkar,项目名称:jax-ws,代码行数:33,代码来源:RequestSignatureHandler.java


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