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


Java SOAPMessageContext类代码示例

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


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

示例1: handleMessage

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
	Boolean request = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
	if (!request) {
		try {
			SOAPMessage msg = context.getMessage();
			SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
			SOAPHeader header = env.getHeader();
			if (header == null) {
				header = env.addHeader();
				return false;
			}
			Node node = (Node) header.getElementsByTagName("token").item(0);
			String token = node.getChildNodes().item(0).getNodeValue();
			if (token != null && token.equals("Kalango Lab")) {
				System.out.println("Token válido");
				return true;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	return true;
}
 
开发者ID:kalangolab,项目名称:programacaoweb,代码行数:27,代码来源:UsuarioHandlerMessage.java

示例2: handleInbound

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
   SOAPMessage soapMessage = msgContext.getMessage();
   Iterator<?> it = soapMessage.getAttachments();
   while(it.hasNext())
   {
      try
      {
         AttachmentPart attachment = (AttachmentPart)it.next();
         System.out.println("Recv " + attachment.getContentType() + " attachment:");
         System.out.println("'"+attachment.getContent()+"'");
         return true;
      }
      catch (SOAPException e)
      {
         throw new RuntimeException("Failed to access attachment data");
      }
   }

   throw new IllegalStateException("Missing attachment on the client side");
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:23,代码来源:JBWS1283TestCase.java

示例3: modifyAssertion

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
private void modifyAssertion(SOAPMessageContext context) throws Exception {
    
    if (isOutboundMessage(context).booleanValue()) {
        Document messageDoc = context.getMessage().getSOAPBody()
                .getOwnerDocument();
        String tagName = getModifyTagName(messageDoc);

        if (tagName != null && tagName.length() != 0) {
            NodeList nodes = messageDoc.getElementsByTagName(tagName);
            if (nodes.getLength() == 0) {
                throw new Exception("Can not modify SAML assertion.");
            }
            Node node = nodes.item(0);
            removeLastCharacter(node);
        }
        
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:19,代码来源:SamlAssertionBreakHandler.java

示例4: exec

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
public void exec(SOAPMessageContext context, ModificationDetail detail)
        throws SOAPException {
    UpdateFieldDetail upd_detail = (UpdateFieldDetail) detail;

    if (!detail.getType().equals(ModificationType.UPDATEFIELD)) {
        return;
    }
    if (detail.getPart().equals(ModificationPart.EXCEPTION)
            || detail.getPart().equals(ModificationPart.METHOD)) {
        return;
    }

    if (detail.getPart().equals(ModificationPart.RETURNVALUE)) {
        updateForResponse(context, upd_detail);
    }

    if (detail.getPart().equals(ModificationPart.PARAMETER)) {
        updateForRequest(context, upd_detail);
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:UpdateFieldAdapter.java

示例5: exec

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
public void exec(SOAPMessageContext soapMessageContext,
        ModificationDetail detail) throws SOAPException {
    if (detail instanceof UpdateDetail) {
        UpdateDetail upd_detail = (UpdateDetail) detail;
        if (ModificationPart.PARAMETER.equals(upd_detail.getPart())) {
            renameParameter(soapMessageContext, upd_detail.getOldVariable()
                    .getVariableName(), upd_detail.getVariable()
                    .getVariableName());
        } else if (ModificationPart.METHOD.equals(upd_detail.getPart())) {
            if (upd_detail.isRequest()) {
                renameMethod(soapMessageContext,
                        METHODPREFIX + upd_detail.getOldMethodName(),
                        METHODPREFIX + upd_detail.getNewMethodName());
            } else {
                renameMethod(soapMessageContext,
                        METHODPREFIX + upd_detail.getOldMethodName()
                                + RESPONSESUFFIX,
                        METHODPREFIX + upd_detail.getNewMethodName()
                                + RESPONSESUFFIX);
            }
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:25,代码来源:UpdateAdapter.java

示例6: renameParameter

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
private void renameParameter(SOAPMessageContext context, String oldName,
        String newName) throws SOAPException {
    NodeList nodelist = context.getMessage().getSOAPBody()
            .getElementsByTagName(oldName);
    Node node;
    if (null != nodelist) {
        int size = nodelist.getLength();
        for (int j = 0; j < size; j++) {
            node = nodelist.item(0);
            if (null != node) {
                Element newNode = node.getOwnerDocument().createElement(
                        newName);
                NodeList list = node.getChildNodes();
                int childrenSize = list.getLength();
                for (int i = 0; i < childrenSize; i++) {
                    newNode.appendChild(list.item(0));
                }
                node.getParentNode().replaceChild(newNode, node);
            }
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:UpdateAdapter.java

示例7: logToSystemOut

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
private void logToSystemOut(SOAPMessageContext smc) {
	if (LOGGER.isDebugEnabled()) {
		StringBuilder sb = new StringBuilder();
		Boolean outboundProperty = (Boolean)smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
		if (outboundProperty.booleanValue())
			sb.append("Missatge SOAP enviat: ");
		else
			sb.append("Missatge SOAP rebut: ");
		SOAPMessage message = smc.getMessage();
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		try {
			message.writeTo(baos);
			sb.append(baos.toString());
		} catch (Exception ex) {
			sb.append("Error al processar el missatge XML: " + ex.getMessage());
		}
		LOGGER.debug(sb.toString());
	}
}
 
开发者ID:GovernIB,项目名称:helium,代码行数:20,代码来源:SoapLoggingHandler.java

示例8: handleMessage

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext c) {

	SOAPMessage msg = c.getMessage();
	boolean request = ((Boolean) c.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY));
	try {
		if (request) { // This is a request message.
			// Write the message to the output stream
			log.debug("Request:\n"
					+ Util.documentToString(msg.getSOAPBody().getOwnerDocument()));
		}
		else { // This is the response message
			log.debug("Response:\n"
					+ Util.documentToString(msg.getSOAPBody().getOwnerDocument()));
		}
	}
	catch (Exception e) {
		log.error(e);
	}

	return Boolean.TRUE;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:23,代码来源:LoggingHandler.java

示例9: handleMessage

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
	Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
	if (!isRequest) { // only incoming messages
		try {
			SOAPMessage soapMsg = context.getMessage();
			SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
			SOAPBody soapBody = soapEnv.getBody();
			if (soapBody != null) {
				// Should have a SOAPBody and a listall response...
				NodeList nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_LIST_ALL_RESPONSE);
				if (nodeList.getLength() > 0) { // check for listAllResponse
												// tag first!
					nodeList = soapBody.getElementsByTagNameNS(EVENTDEF_NS, EVENTDEF_ELEMENT);
					recursiveRenamespace(nodeList); // renamespace...
					soapMsg.saveChanges();
				}
			}
		} catch (Exception e) {
			catchMessages(e);
		}
	}
	return true;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:25,代码来源:EventDefListAllHandler.java

示例10: handleMessage

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
public boolean handleMessage(SOAPMessageContext context) {
	Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
	if (!isRequest) { // only incoming messages
		try {
			SOAPMessage soapMsg = context.getMessage();
			SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
			SOAPBody soapBody = soapEnv.getBody();
			if (soapBody != null) {
				// Should have a SOAPBody and a listall response...
				NodeList nodeList = soapBody.getElementsByTagNameNS(STUDIES_NS, STUDY_LIST_ALL_RESPONSE);
				if (nodeList.getLength() > 0) { // check for listAllResponse
												// tag first!
					nodeList = soapBody.getElementsByTagNameNS(STUDIES_NS, STUDIES_ELEMENT);
					recursiveRenamespace(nodeList); // renamespace...
					soapMsg.saveChanges();
				}
			}
		} catch (Exception e) {
			catchMessages(e);
		}
	}
	return true;
}
 
开发者ID:ddRPB,项目名称:rpb,代码行数:25,代码来源:StudyListAllHandler.java

示例11: handleMessage

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
public boolean handleMessage(SOAPMessageContext messagecontext) {
    Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (outbound) {
        try {
            SOAPMessage soapMessage = messagecontext.getMessage();
            SOAPBody soapBody = soapMessage.getSOAPBody();
            Node firstChild = soapBody.getFirstChild();

            String timeStamp = getTimestamp();
            String signature = getSignature(firstChild.getLocalName(), timeStamp, secretBytes);

            appendTextElement(firstChild, "Signature", signature);
            appendTextElement(firstChild, "Timestamp", timeStamp);
        } catch(SOAPException se) {
            throw new RuntimeException("SOAPException was thrown.", se);
        }
    }
    return true;
}
 
开发者ID:sasinda,项目名称:OntologyBasedInormationExtractor,代码行数:20,代码来源:AwsHandlerResolver.java

示例12: handleInbound

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
protected boolean handleInbound(SOAPMessageContext msgContext)
{
   log.info("handleInbound");

   try
   {
      SOAPMessage soapMessage = msgContext.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();

      SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
      SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
      String value = soapElement.getValue();
      soapElement.setValue(value + "|RoutIn");
   }
   catch (SOAPException e)
   {
      throw  new WebServiceException(e);
   }

   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:23,代码来源:RoutingHandler.java

示例13: handleOutbound

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
@Override
protected boolean handleOutbound(SOAPMessageContext msgContext)
{
   log.info("handleOutbound");

   try
   {
      SOAPMessage soapMessage = msgContext.getMessage();
      SOAPBody soapBody = soapMessage.getSOAPBody();

      SOAPBodyElement soapBodyElement = (SOAPBodyElement)soapBody.getChildElements().next();
      SOAPElement soapElement = (SOAPElement)soapBodyElement.getChildElements().next();
      String value = soapElement.getValue();
      soapElement.setValue(value + "|CustomOut");
   }
   catch (SOAPException e)
   {
      throw  new WebServiceException(e);
   }

   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:23,代码来源:CustomHandler.java

示例14: verifyXOPPackage

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
private boolean verifyXOPPackage(MessageContext context)
{
   try
   {
      SOAPMessageContext msgContext = (SOAPMessageContext)context;
      SOAPMessage soapMsg = msgContext.getMessage();
      SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
      SOAPBody body = soapEnv.getBody();
      boolean found = scanNodes(body.getChildNodes());

      if(found) throw new IllegalStateException("XOP request not properly inlined");

   }
   catch (SOAPException ex)
   {
      throw new WebServiceException(ex);
   }

   return true;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:21,代码来源:MTOMProtocolHandler.java

示例15: logMessage

import javax.xml.ws.handler.soap.SOAPMessageContext; //导入依赖的package包/类
private void logMessage(SOAPMessageContext context) {
	Boolean outboundProperty = (Boolean) context
			.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
	LOG.debug("outbound message: " + outboundProperty);
	SOAPMessage soapMessage = context.getMessage();
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	try {
		soapMessage.writeTo(outputStream);
	} catch (Exception e) {
		LOG.error("SOAP error: " + e.getMessage());
	}
	String message = outputStream.toString();
	LOG.debug("SOAP message: " + message);
	if (false == outboundProperty) {
		@SuppressWarnings("unchecked")
		Map<String, DataHandler> inboundMessageAttachments = (Map<String, DataHandler>) context
				.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
		Set<String> attachmentContentIds = inboundMessageAttachments
				.keySet();
		LOG.debug("attachment content ids: " + attachmentContentIds);
	}
}
 
开发者ID:e-Contract,项目名称:mycarenet,代码行数:23,代码来源:LoggingHandler.java


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