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


Java MessageContext类代码示例

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


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

示例1: createWebServiceContextMock

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
private WebServiceContext createWebServiceContextMock(String expectedIP,
        String expectedUser) {
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getRemoteAddr()).thenReturn(expectedIP);

    Principal principalMock = mock(Principal.class);
    when(principalMock.getName()).thenReturn(expectedUser);

    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(anyString())).thenReturn(requestMock);

    WebServiceContext wsContextMock = mock(WebServiceContext.class);
    when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);

    return wsContextMock;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:CategorizationServiceWSTest.java

示例2: getCaller

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
/**
 * @return a token which contains a random Unique ID per caller and the caller IP as well
 */
private String getCaller() {

    MessageContext msgx = wsContext.getMessageContext();

    HttpServletRequest request = ((HttpServletRequest) msgx.get(MessageContext.SERVLET_REQUEST));

    String uid = "";
    try {
        Map<String, List<String>> headers = (Map<String, List<String>>) msgx.get(MessageContext.HTTP_REQUEST_HEADERS);
        uid = headers.get(ApplicationContext.ATS_UID_SESSION_TOKEN).get(0);
    } catch (Exception e) {
        if (!alreadyLoggedErrorAboutSessionUid) {
            log.warn("Could not get ATS UID for call from " + request.getRemoteAddr()
                     + ". This error will not be logged again before Agent restart.", e);
            alreadyLoggedErrorAboutSessionUid = true;
        }
    }

    return "<Caller: " + request.getRemoteAddr() + "; ATS UID: " + uid + ">";
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:24,代码来源:AgentWsImpl.java

示例3: closeServersideHandlers

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
/**
 * Called by close(MessageContext mc) in a Server Handlertube
 */
protected void closeServersideHandlers(MessageContext msgContext) {
    if (processor == null)
        return;
    if (remedyActionTaken) {
        //Close only invoked handlers in the chain

        //SERVER-SIDE
        processor.closeHandlers(msgContext, processor.getIndex(), handlers.size() - 1);
        processor.setIndex(-1);
        //reset remedyActionTaken
        remedyActionTaken = false;
    } else {
        //Close all handlers in the chain

        //SERVER-SIDE
        processor.closeHandlers(msgContext, 0, handlers.size() - 1);

    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:HandlerTube.java

示例4: callHandlersOnResponse

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {
    //Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
    Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    AttachmentSet attSet = context.packet.getMessage().getAttachments();
    for (Entry<String, DataHandler> entry : atts.entrySet()) {
        String cid = entry.getKey();
        if (attSet.get(cid) == null) { // Otherwise we would be adding attachments twice
            Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
            attSet.add(att);
        }
    }

    try {
        //SERVER-SIDE
        processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);

    } catch (WebServiceException wse) {
        //no rewrapping
        throw wse;
    } catch (RuntimeException re) {
        throw re;

    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:ServerMessageHandlerTube.java

示例5: get

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
@Override
@SuppressWarnings("element-type-mismatch")
public Object get(Object key) {
    if (packet.supports(key)) {
        return packet.get(key);    // strongly typed
    }
    if (packet.getHandlerScopePropertyNames(true).contains(key)) {
        return null;            // no such application-scope property
    }
    Object value =  packet.invocationProperties.get(key);

    //add the attachments from the Message to the corresponding attachment property
    if(key.equals(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS) ||
            key.equals(MessageContext.INBOUND_MESSAGE_ATTACHMENTS)){
        Map<String, DataHandler> atts = (Map<String, DataHandler>) value;
        if(atts == null)
            atts = new HashMap<String, DataHandler>();
        AttachmentSet attSet = packet.getMessage().getAttachments();
        for(Attachment att : attSet){
            atts.put(att.getContentId(), att.asDataHandler());
        }
        return atts;
    }
    return value;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:EndpointMessageContextImpl.java

示例6: callHandlersOnResponse

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {

        //Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
        Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
        AttachmentSet attSet = context.packet.getMessage().getAttachments();
        for (Map.Entry<String, DataHandler> entry : atts.entrySet()) {
            String cid = entry.getKey();
            if (attSet.get(cid) == null) { // Otherwise we would be adding attachments twice
                Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
                attSet.add(att);
            }
        }

        try {
            //SERVER-SIDE
            processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);

        } catch (WebServiceException wse) {
            //no rewrapping
            throw wse;
        } catch (RuntimeException re) {
            throw re;

        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:ServerSOAPHandlerTube.java

示例7: callHandlersOnResponse

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {
    //Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
    Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    AttachmentSet attSet = context.packet.getMessage().getAttachments();
    for (Entry<String, DataHandler> entry : atts.entrySet()) {
        String cid = entry.getKey();
        Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
        attSet.add(att);
    }

    try {
        //SERVER-SIDE
        processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);

    } catch (WebServiceException wse) {
        //no rewrapping
        throw wse;
    } catch (RuntimeException re) {
        throw re;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:ServerLogicalHandlerTube.java

示例8: close

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
/**
 * Calls close on previously invoked handlers.
 * Also, Cleans up any state left over in the Tube instance from the current
 * invocation, as Tube instances can be reused after the completion of MEP.
 *
 * On Client, SOAPHandlers are closed first and then LogicalHandlers
 * On Server, LogicalHandlers are closed first and then SOAPHandlers
 */
final public void close(MessageContext msgContext) {
    //assuming cousinTube is called if requestProcessingSucessful is true
    if (requestProcessingSucessful) {
        if (cousinTube != null) {
            cousinTube.close(msgContext);
        }

    }
    if (processor != null)
        closeHandlers(msgContext);

    // Clean up the exchange for next invocation.
    exchange = null;
    requestProcessingSucessful = false;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:HandlerTube.java

示例9: closeClientsideHandlers

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
/**
 * Called by close(MessageContext mc) in a Client Handlertube
 */
protected void closeClientsideHandlers(MessageContext msgContext) {
     if (processor == null)
        return;
    if (remedyActionTaken) {
        //Close only invoked handlers in the chain

        //CLIENT-SIDE
        processor.closeHandlers(msgContext, processor.getIndex(), 0);
        processor.setIndex(-1);
        //reset remedyActionTaken
        remedyActionTaken = false;
    } else {
        //Close all handlers in the chain

        //CLIENT-SIDE
        processor.closeHandlers(msgContext, handlers.size() - 1, 0);

    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:HandlerTube.java

示例10: createPacket

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
Packet createPacket(SOAPMessage arg) {
    Iterator iter = arg.getMimeHeaders().getAllHeaders();
    Headers ch = new Headers();
    while(iter.hasNext()) {
        MimeHeader mh = (MimeHeader) iter.next();
        ch.add(mh.getName(), mh.getValue());
    }
    Packet packet = new Packet(SAAJFactory.create(arg));
    packet.invocationProperties.put(MessageContext.HTTP_REQUEST_HEADERS, ch);
    return packet;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:SOAPMessageDispatch.java

示例11: handleMessage

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

    // Indicator telling us which direction this message is going in
    final Boolean outInd = (Boolean) msgCtx.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

    // Handler must only add security headers to outbound messages
    if (outInd.booleanValue()) {
        try {
            // Get the SOAP Envelope
            final SOAPEnvelope envelope = msgCtx.getMessage().getSOAPPart().getEnvelope();

            // Header may or may not exist yet
            SOAPHeader header = envelope.getHeader();
            if (header == null)
                header = envelope.addHeader();

            // Add WSS Usertoken Element Tree 
            final SOAPElement security = header.addChildElement("Security", "wsse",
                    "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
            final SOAPElement userToken = security.addChildElement("UsernameToken", "wsse");
            userToken.addChildElement("Username", "wsse").addTextNode(userId);
            userToken.addChildElement("Password", "wsse").addAttribute(new QName("Type"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText").addTextNode(password);

        } catch (final Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    return true;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:32,代码来源:SOAPSecurityHandler.java

示例12: handleMessage

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
/**
 * The method is invoked for normal processing of outbound messages.
 * 
 * @param context
 *            the message context.
 * @return An indication of whether handler processing should continue for
 *         the current message. Return <code>true</code> to continue
 *         processing.
 * 
 * @throws Exception
 *             Causes the JAX-WS runtime to cease fault message processing.
 **/
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean request_p = (Boolean) context
            .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (request_p.booleanValue()) {
        try {
            SOAPMessage msg = context.getMessage();
            SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
            SOAPHeader hdr = env.getHeader();
            if (hdr == null) {
                hdr = env.addHeader();
            }
            QName qname_user = new QName("http://com/auth/", "auth");
            SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
            helem_user.setActor(VERSION);
            if (version != null && version.trim().length() != 0) {
                helem_user.addTextNode(version);
            }

            msg.saveChanges();
            message = soapMessage2String(msg);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return true;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:41,代码来源:VersionHandlerCtmg.java

示例13: getReferenceParameters

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
/**
 * Gives a list of Reference Parameters in the Message
 * <p>
 * Headers which have attribute wsa:IsReferenceParameter="true"
 * This is not cached as one may reset the Message.
 *<p>
 */
@Property(MessageContext.REFERENCE_PARAMETERS)
public
@NotNull
List<Element> getReferenceParameters() {
    Message msg = getMessage();
    List<Element> refParams = new ArrayList<Element>();
    if (msg == null) {
        return refParams;
    }
    MessageHeaders hl = msg.getHeaders();
    for (Header h : hl.asList()) {
        String attr = h.getAttribute(AddressingVersion.W3C.nsUri, "IsReferenceParameter");
        if (attr != null && (attr.equals("true") || attr.equals("1"))) {
            Document d = DOMUtil.createDom();
            SAX2DOMEx s2d = new SAX2DOMEx(d);
            try {
                h.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
                refParams.add((Element) d.getLastChild());
            } catch (SAXException e) {
                throw new WebServiceException(e);
            }
            /*
            DOMResult result = new DOMResult(d);
            XMLDOMWriterImpl domwriter = new XMLDOMWriterImpl(result);
            try {
                h.writeTo(domwriter);
                refParams.add((Element) result.getNode().getLastChild());
            } catch (XMLStreamException e) {
                throw new WebServiceException(e);
            }
            */
        }
    }
    return refParams;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:Packet.java

示例14: handleMessage

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
/**
 * The method is invoked for normal processing of outbound messages.
 * 
 * @param context
 *            the message context.
 * @return An indication of whether handler processing should continue for
 *         the current message. Return <code>true</code> to continue
 *         processing.
 * 
 * @throws Exception
 *             Causes the JAX-WS runtime to cease fault message processing.
 **/
@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean request_p = (Boolean) context
            .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (request_p.booleanValue()) {
        try {
            SOAPMessage msg = context.getMessage();
            SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
            SOAPHeader hdr = env.getHeader();
            if (hdr == null) {
                hdr = env.addHeader();
            }
            QName qname_user = new QName("http://com/auth/", "auth");
            SOAPHeaderElement helem_user = hdr.addHeaderElement(qname_user);
            helem_user.setActor(VERSION);
            if (version == null || version.trim().length() == 0) {
                helem_user.addTextNode(apiVersionInfo.getProperty(VERSION));
            } else {
                helem_user.addTextNode(version);
            }

            msg.saveChanges();
            message = soapMessage2String(msg);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return true;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:43,代码来源:VersionHandler.java

示例15: setup

import javax.xml.ws.handler.MessageContext; //导入依赖的package包/类
@Before
public void setup() {

    httpRequestMock = mock(HttpServletRequest.class);
    when(httpRequestMock.getHeader("x-forwarded-for"))
            .thenReturn("1.1.1.1");
    when(httpRequestMock.getHeader("X-Forwarded-For"))
            .thenReturn("1.1.1.2");
    when(httpRequestMock.getRemoteAddr()).thenReturn("255.255.255.255");
    wsContextMock = mock(WebServiceContext.class);
    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(MessageContext.SERVLET_REQUEST)).thenReturn(
            httpRequestMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:16,代码来源:IPResolverTest.java


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