Java 类javax.xml.ws.LogicalMessage 实例源码

项目:wso2-axis2    文件:LogicalMessageContextTests.java   
/**
 * 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);            
    }
}
项目:wso2-axis2    文件:LogicalMessageContextTests.java   
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));
}
项目:wso2-axis2    文件:CompositeMessageContextTests.java   
/**
 * 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);
}
项目:wso2-axis2    文件:CompositeMessageContextTests.java   
/**
 * 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);
}
项目:mycarenet    文件:PayloadLogicalHandler.java   
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);
}
项目:jax-ws    文件:RequestSignatureHandler.java   
@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;
   }
项目:wso2-axis2    文件:LogicalMessageContextTests.java   
/**
 * Test the javax.xml.transform.Source based APIs on the LogicalMessage interface.
 * @throws Exception
 */
public void testGetPayloadAsSource() 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);
    assertTrue("The content returned was incomplete, unexpected element", resultContent.indexOf("echoString") > -1);
    assertTrue("The content returned was incomplete, unexpected content", resultContent.indexOf(INPUT) > -1);
}
项目:wso2-axis2    文件:LogicalMessageContextTests.java   
/**
 * Tests the setting of the payload and make sure we don't cache improperly.
 * @throws Exception
 */
public void testGetAndSetPayloadAsSource() 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);
    assertTrue("The content returned was incorrect", resultContent.indexOf(INPUT) > 0);

    // Now manipluate the content and set it back on the message.
    int start = resultContent.indexOf(INPUT);
    int end = start + INPUT.length();

    String newInput = "new content goes here";
    String newContent = resultContent.substring(0, start) + newInput + resultContent.substring(end);

    ByteArrayInputStream bais = new ByteArrayInputStream(newContent.getBytes());
    StreamSource newPayload = new StreamSource(bais); 

    msg.setPayload(newPayload);

    // Check the payload to make sure the new content that we added 
    // was insterted correctly.
    Source payload2 = msg.getPayload();
    assertTrue("The returned payload (Source) was null", payload2 != null);

    String resultContent2 = _getStringFromSource(payload2);
    assertTrue("The updated content returned was null", resultContent2 != null);
    assertTrue("The updated content returned was incorrect, old content found", resultContent2.indexOf(INPUT) < 0);
    assertTrue("The updated content returned was incorrect, new content not found", resultContent2.indexOf(newInput) > -1);
}
项目:wso2-axis2    文件:LogicalMessageContextTests.java   
/**
 * Tests the setting of the payload when the original content is a fault.
 * @throws Exception
 */
public void testGetAndSetFaultPayloadAsSource() throws Exception {
    LogicalMessageContext lmc = createSampleFaultContext();

    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);
    assertTrue("The content returned was incorrect", resultContent.indexOf(FAULT_INPUT) > 0);
    assertTrue("The content returned was incorrect, no fault found", resultContent.indexOf("Fault") > 0);

    // Now manipluate the content and set it back on the message.
    int start = resultContent.indexOf(FAULT_INPUT);
    int end = start + FAULT_INPUT.length();

    String newFaultInput = "new fault content goes here";
    String newContent = resultContent.substring(0, start) + newFaultInput + resultContent.substring(end);

    ByteArrayInputStream bais = new ByteArrayInputStream(newContent.getBytes());
    StreamSource newPayload = new StreamSource(bais); 

    msg.setPayload(newPayload);

    // Check the payload to make sure the new content that we added 
    // was insterted correctly.
    Source payload2 = msg.getPayload();
    assertTrue("The returned payload (Source) was null", payload2 != null);

    String resultContent2 = _getStringFromSource(payload2);
    assertTrue("The updated content returned was null", resultContent2 != null);
    assertTrue("The updated content returned was incorrect, old content found", resultContent2.indexOf(FAULT_INPUT) < 0);
    assertTrue("The updated content returned was incorrect, no fault found", resultContent.indexOf("Fault") > 0);
    assertTrue("The updated content returned was incorrect, new content not found", resultContent2.indexOf(newFaultInput) > -1);
}
项目:wso2-axis2    文件:AddNumbersClientLogicalHandler3.java   
public boolean handleFault(LogicalMessageContext messagecontext) {
    Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    tracker.handleFault(outbound);
    // let's see if we can do this
    LogicalMessage lm = messagecontext.getMessage();
    String s = getStringFromSourcePayload(lm.getPayload());
    tracker.log("RETURNING FALSE", outbound);
    return false;
}
项目:wso2-axis2    文件:AddNumbersClientLogicalHandler2.java   
public boolean handleMessage(LogicalMessageContext messagecontext) {
    Boolean outbound = (Boolean)messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    tracker.handleMessage(outbound);
    if (outbound) {  // outbound request on the client
        LogicalMessage msg = messagecontext.getMessage();
        Source payload = msg.getPayload();
        String st = getStringFromSourcePayload(payload);
        String txt = String.valueOf(Integer.valueOf(getFirstArg(st)) * 2);
        st = replaceFirstArg(st, txt);
        msg.setPayload(new StreamSource(new StringBufferInputStream(st)));
    }
    return true;
}
项目:wso2-axis2    文件:AddNumbersLogicalHandler2.java   
public boolean handleFault(LogicalMessageContext messagecontext) {
    Boolean outbound = (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    tracker.handleFault(outbound);
    if (outbound) {  // outbound response if we're on the server
        LogicalMessage msg = messagecontext.getMessage();
        String st = getStringFromSourcePayload(msg.getPayload());
        st = st.replaceFirst("blarg", "AddNumbersLogicalHandler2 was here");
        msg.setPayload(new StreamSource(new ByteArrayInputStream(st.getBytes())));
    }
    return true;
}
项目:OpenJSharp    文件:LogicalMessageContextImpl.java   
public LogicalMessage getMessage() {
    if(lm == null)
        lm = new LogicalMessageImpl(defaultJaxbContext, packet);
    return lm;
}
项目:openjdk-jdk10    文件:LogicalMessageContextImpl.java   
public LogicalMessage getMessage() {
    if(lm == null)
        lm = new LogicalMessageImpl(defaultJaxbContext, packet);
    return lm;
}
项目:openjdk9    文件:LogicalMessageContextImpl.java   
public LogicalMessage getMessage() {
    if(lm == null)
        lm = new LogicalMessageImpl(defaultJaxbContext, packet);
    return lm;
}
项目:lookaside_java-1.8.0-openjdk    文件:LogicalMessageContextImpl.java   
public LogicalMessage getMessage() {
    if(lm == null)
        lm = new LogicalMessageImpl(defaultJaxbContext, packet);
    return lm;
}
项目:jaxws-maven-plugin    文件:WSClientHandler.java   
@Override
public boolean handleMessage(LogicalMessageContext messageContext) {
    LogicalMessage msg = messageContext.getMessage();
    return true;
}
项目:infobip-open-jdk-8    文件:LogicalMessageContextImpl.java   
public LogicalMessage getMessage() {
    if(lm == null)
        lm = new LogicalMessageImpl(defaultJaxbContext, packet);
    return lm;
}
项目:jax-ws    文件:ProviderErrorHandler.java   
@Override
   public boolean handleFault(LogicalMessageContext msgCtx) {
boolean outbound = Boolean.TRUE.equals(msgCtx
    .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY));

if (outbound) {
    LogicalMessage msg = msgCtx.getMessage();

    DOMResult dom = new DOMResult();
    try {
    Source payload = msg.getPayload();

    Node node = null;
    // If payload is not a DomSource, need to transform
    if (!(payload instanceof DOMSource)) {
        Transformer tf = TransformerFactory.newInstance()
            .newTransformer();
        tf.transform(payload, dom);

        node = dom.getNode();
    } else {
        node = ((DOMSource) payload).getNode();
    }

    Node fault = node.getFirstChild();

    Node faultCode = fault.getFirstChild();

    Node faultString = faultCode.getNextSibling();

    Node detail = faultString.getNextSibling();

    // Remove the detail stacktrace, client doesn't need to see it
    if (detail != null) {
        fault.removeChild(detail);
    }

    // If payload is not a DomSource, need to set back
    if (!(payload instanceof DOMSource)) {
        LOGGER.debug("Alas, payload is not a DomSource, it is {}.",
            payload.getClass().getName());
        payload = new DOMSource(fault);

        msg.setPayload(payload);
    }
    } catch (Exception e) {
    LOGGER.error(e.getMessage(), e);

    return false;
    }
}

return true;
   }
项目:OLD-OpenJDK8    文件:LogicalMessageContextImpl.java   
public LogicalMessage getMessage() {
    if(lm == null)
        lm = new LogicalMessageImpl(defaultJaxbContext, packet);
    return lm;
}
项目:wso2-axis2    文件:LogicalMessageContext.java   
public LogicalMessage getMessage() {
    return new LogicalMessageImpl(messageCtx.getMEPContext());
}
项目:openjdk-icedtea7    文件:LogicalMessageContextImpl.java   
public LogicalMessage getMessage() {
    if(lm == null)
        lm = new LogicalMessageImpl(defaultJaxbContext, packet);
    return lm;
}
项目:jax-ws    文件:HandlerUtil.java   
public void prettyPrintLogicalMessage(LogicalMessage logicalMessage) {

    Source payload = logicalMessage.getPayload();

    StreamResult result = (StreamResult) transform(payload);

    LOGGER.debug("Payload: \n{}.", result.getWriter().toString());
    }
项目:OpenJSharp    文件:LogicalMessageContext.java   
/** Gets the message from this message context
 *
 *  @return The contained message; returns <code>null</code> if no
 *          message is present in this message context
**/
public LogicalMessage getMessage();
项目:openjdk-jdk10    文件:LogicalMessageContext.java   
/** Gets the message from this message context
 *
 *  @return The contained message; returns {@code null} if no
 *          message is present in this message context
**/
public LogicalMessage getMessage();
项目:openjdk9    文件:LogicalMessageContext.java   
/** Gets the message from this message context
 *
 *  @return The contained message; returns {@code null} if no
 *          message is present in this message context
**/
public LogicalMessage getMessage();
项目:Java8CN    文件:LogicalMessageContext.java   
/** Gets the message from this message context
 *
 *  @return The contained message; returns <code>null</code> if no
 *          message is present in this message context
**/
public LogicalMessage getMessage();
项目:lookaside_java-1.8.0-openjdk    文件:LogicalMessageContext.java   
/** Gets the message from this message context
 *
 *  @return The contained message; returns <code>null</code> if no
 *          message is present in this message context
**/
public LogicalMessage getMessage();
项目:infobip-open-jdk-8    文件:LogicalMessageContext.java   
/** Gets the message from this message context
 *
 *  @return The contained message; returns <code>null</code> if no
 *          message is present in this message context
**/
public LogicalMessage getMessage();
项目:OLD-OpenJDK8    文件:LogicalMessageContext.java   
/** Gets the message from this message context
 *
 *  @return The contained message; returns <code>null</code> if no
 *          message is present in this message context
**/
public LogicalMessage getMessage();
项目:openjdk-icedtea7    文件:LogicalMessageContext.java   
/** Gets the message from this message context
 *
 *  @return The contained message; returns <code>null</code> if no
 *          message is present in this message context
**/
public LogicalMessage getMessage();