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


Java MessageContext.setOperationContext方法代码示例

本文整理汇总了Java中org.apache.axis2.context.MessageContext.setOperationContext方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setOperationContext方法的具体用法?Java MessageContext.setOperationContext怎么用?Java MessageContext.setOperationContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axis2.context.MessageContext的用法示例。


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

示例1: send

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Synchronously send the request and receive a response. This relies on the transport correctly connecting the
 * response InputStream!
 *
 * @param msgContext the request MessageContext to send.
 * @return Returns MessageContext.
 * @throws AxisFault Sends the message using a two way transport and waits for a response
 */
protected MessageContext send(final MessageContext msgContext) throws AxisFault {

// create the responseMessageContext
    final MessageContext responseMessageContext
            = msgContext.getConfigurationContext().createMessageContext();

    responseMessageContext.setServerSide(false);
    responseMessageContext.setOperationContext(msgContext.getOperationContext());
    responseMessageContext.setOptions(new Options(options));
    responseMessageContext.setMessageID(msgContext.getMessageID());
    addMessageContext(responseMessageContext);
    responseMessageContext.setServiceContext(msgContext.getServiceContext());
    responseMessageContext.setAxisMessage(
            axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));

    //sending the message
    AxisEngine.send(msgContext);

    responseMessageContext.setDoingREST(msgContext.isDoingREST());

// Copy RESPONSE properties which the transport set onto the request message context when it processed
    // the incoming response recieved in reply to an outgoing request.
    responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
            msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
    responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
            msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));

    responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
            .getProperty(MessageContext.TRANSPORT_IN));
    responseMessageContext.setTransportIn(msgContext.getTransportIn());
    responseMessageContext.setTransportOut(msgContext.getTransportOut());
    handleResponse(responseMessageContext);
    return responseMessageContext;
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:43,代码来源:OutOptInAxisOperation.java

示例2: createMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc, ConfigurationContext cc,
                                                int flowType) throws Exception {
        MessageContext mc = cc.createMessageContext();

        mc.setFLOW(flowType);
        mc.setTransportIn(transportIn);
        mc.setTransportOut(transportOut);

        mc.setServerSide(true);
//        mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);

        SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
        mc.setEnvelope(omFac.getDefaultEnvelope());

        AxisOperation axisOperation = oc.getAxisOperation();
        String action = axisOperation.getName().getLocalPart();
        mc.setSoapAction(action);
//        System.out.flush();

        mc.setMessageID(UUIDGenerator.getUUID());

        axisOperation.registerOperationContext(mc, oc);
        mc.setOperationContext(oc);

        ServiceContext sc = oc.getServiceContext();
        mc.setServiceContext(sc);

        mc.setTo(new EndpointReference("axis2/services/NullService"));
        mc.setWSAAction("DummyOp");

        AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        mc.setAxisMessage(axisMessage);

        return mc;
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:36,代码来源:MessageContextSaveCTest.java

示例3: createMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc) throws Exception {
        MessageContext mc = configurationContext.createMessageContext();
        mc.setTransportIn(transportIn);
        mc.setTransportOut(transportOut);

        mc.setServerSide(true);
//        mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);

        SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
        mc.setEnvelope(omFac.getDefaultEnvelope());

        AxisOperation axisOperation = oc.getAxisOperation();
        String action = axisOperation.getName().getLocalPart();
        mc.setSoapAction(action);
//        System.out.flush();

        mc.setMessageID(UUIDGenerator.getUUID());

        axisOperation.registerOperationContext(mc, oc);
        mc.setOperationContext(oc);

        ServiceContext sc = oc.getServiceContext();
        mc.setServiceContext(sc);

        mc.setTo(new EndpointReference("axis2/services/NullService"));
        mc.setWSAAction("DummyOp");

        AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        mc.setAxisMessage(axisMessage);

        return mc;
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:33,代码来源:MessageContextSaveBTest.java

示例4: send

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Synchronously send the request and receive a response.  This relies on the transport
 * correctly connecting the response InputStream!
 *
 * @param msgContext the request MessageContext to send.
 * @return Returns MessageContext.
 * @throws AxisFault Sends the message using a two way transport and waits for a response
 */
protected MessageContext send(MessageContext msgContext) throws AxisFault {

    // create the responseMessageContext

    MessageContext responseMessageContext =
            msgContext.getConfigurationContext().createMessageContext();

    responseMessageContext.setServerSide(false);
    responseMessageContext.setOperationContext(msgContext.getOperationContext());
    responseMessageContext.setOptions(new Options(options));
    responseMessageContext.setMessageID(msgContext.getMessageID());
    addMessageContext(responseMessageContext);
    responseMessageContext.setServiceContext(msgContext.getServiceContext());
    responseMessageContext.setAxisMessage(
            axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));

    //sending the message
    AxisEngine.send(msgContext);

    responseMessageContext.setDoingREST(msgContext.isDoingREST());

    // Copy RESPONSE properties which the transport set onto the request message context when it processed
    // the incoming response recieved in reply to an outgoing request.
    responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
            msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
    responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
            msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));

    responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
            .getProperty(MessageContext.TRANSPORT_IN));
    responseMessageContext.setTransportIn(msgContext.getTransportIn());
    responseMessageContext.setTransportOut(msgContext.getTransportOut());
    handleResponse(responseMessageContext);
    return responseMessageContext;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:44,代码来源:OutInAxisOperation.java

示例5: registerOperationContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void registerOperationContext(MessageContext msgContext,
                                     OperationContext operationContext)
        throws AxisFault {
    msgContext.setAxisOperation(this);
    msgContext.getConfigurationContext().registerOperationContext(msgContext.getMessageID(),
                                                                  operationContext);
    operationContext.addMessageContext(msgContext);
    msgContext.setOperationContext(operationContext);
    if (operationContext.isComplete()) {
        operationContext.cleanup();
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:13,代码来源:AxisOperation.java

示例6: registerMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void registerMessageContext(MessageContext msgContext,
                                   OperationContext operationContext) throws AxisFault {
    msgContext.setAxisOperation(this);
    operationContext.addMessageContext(msgContext);
    msgContext.setOperationContext(operationContext);
    if (operationContext.isComplete()) {
        operationContext.cleanup();
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:10,代码来源:AxisOperation.java

示例7: testDoProcessing

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
    MessageMetaData mmd = TestUtils.getMMD("security/handlers/full_mmd.xml", this);
    // Creating SOAP envelope
    SOAPEnvelope env =
            SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);
    // Adding UserMessage from mmd
    OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);

    MessageContext mc = new MessageContext();

    System.out.println("mc: " + mc);

    mc.setFLOW(MessageContext.IN_FLOW);
    mc.setProperty(SecurityConstants.ADD_SECURITY_HEADERS, Boolean.TRUE);

    UserMessage userMessage = UserMessageElement.readElement(umElement);

    OperationContext operationContext = mock(OperationContext.class);
    when(operationContext
            .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
            .thenReturn(mc);

    mc.setOperationContext(operationContext);

    try {
        mc.setEnvelope(env);
    } catch (AxisFault axisFault) {
        fail(axisFault.getMessage());
    }

    StorageManager storageManager = core.getStorageManager();
    // Setting input message property
    IUserMessageEntity userMessageEntity =
            storageManager.storeIncomingMessageUnit(userMessage);
    mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
            userMessageEntity);

    SecurityConstants.WSS_FAILURES part =
            SecurityConstants.WSS_FAILURES.DECRYPTION;
    String errorMessage = "some error message";

    mc.setProperty(SecurityConstants.INVALID_DEFAULT_HEADER,
            new KeyValuePair<>(part, errorMessage));

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    assertEquals(ProcessingState.FAILURE,
            userMessageEntity.getCurrentProcessingState().getState());
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:58,代码来源:ProcessSecurityFaultTest.java

示例8: testDoProcessing

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
    MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
    // Creating SOAP envelope
    SOAPEnvelope env =
            SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);
    // Adding UserMessage from mmd
    OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);

    MessageContext mc = new MessageContext();
    mc.setFLOW(MessageContext.OUT_FLOW);

    UserMessage userMessage = UserMessageElement.readElement(umElement);

    OperationContext operationContext = mock(OperationContext.class);
    when(operationContext
            .getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE))
            .thenReturn(mc);

    mc.setOperationContext(operationContext);

    try {
        mc.setEnvelope(env);
    } catch (AxisFault axisFault) {
        fail(axisFault.getMessage());
    }

    StorageManager storageManager = core.getStorageManager();
    // Setting input message property
    IUserMessageEntity userMessageEntity =
            storageManager.storeIncomingMessageUnit(userMessage);
    mc.setProperty(MessageContextProperties.OUT_USER_MESSAGE,
            userMessageEntity);

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    assertEquals(ProcessingState.SENDING,
            userMessageEntity.getCurrentProcessingState().getState());
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:47,代码来源:CheckSentResultTest.java

示例9: testDoProcessingOfTheUserMessage

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfTheUserMessage() throws Exception {
    MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);
    // Adding UserMessage from mmd
    OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);

    UserMessage userMessage = UserMessageElement.readElement(umElement);

    String pmodeId =
            userMessage.getCollaborationInfo().getAgreement().getPModeId();
    userMessage.setPModeId(pmodeId);

    MessageContext mc = new MessageContext();
    mc.setServerSide(true);
    mc.setFLOW(MessageContext.OUT_FLOW);

    // Setting input message property
    IUserMessageEntity userMessageEntity =
            core.getStorageManager().storeIncomingMessageUnit(userMessage);
    mc.setProperty(MessageContextProperties.OUT_USER_MESSAGE,
            userMessageEntity);

    // Mocking the Axis2 Operation Context
    OperationContext operationContext = mock(OperationContext.class);
    when(operationContext
            .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
            .thenReturn(mc);

    mc.setOperationContext(operationContext);

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertNotNull(invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    verify(mockAppender, atLeastOnce())
            .doAppend(captorLoggingEvent.capture());
    List<LoggingEvent> events = captorLoggingEvent.getAllValues();
    String msg = "Response contains an user message unit";
    assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:48,代码来源:PrepareResponseMessageTest.java

示例10: testDoProcessingOfTheResponseReceipt

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfTheResponseReceipt() throws Exception {
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);

    MessageContext mc = new MessageContext();
    mc.setServerSide(true);
    mc.setFLOW(MessageContext.OUT_FLOW);

    Receipt receipt = new Receipt();
    OMElement receiptChildElement =
            env.getOMFactory().createOMElement(RECEIPT_CHILD_ELEMENT_NAME);
    ArrayList<OMElement> content = new ArrayList<>();
    content.add(receiptChildElement);
    receipt.setContent(content);

    ReceiptElement.createElement(headerBlock, receipt);

    StorageManager updateManager = core.getStorageManager();
    IReceiptEntity receiptEntity =
            updateManager.storeIncomingMessageUnit(receipt);
    mc.setProperty(MessageContextProperties.RESPONSE_RECEIPT, receiptEntity);

    // Mocking the Axis2 Operation Context
    OperationContext operationContext = mock(OperationContext.class);
    when(operationContext
            .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
            .thenReturn(mc);

    mc.setOperationContext(operationContext);

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertNotNull(invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    verify(mockAppender, atLeastOnce())
            .doAppend(captorLoggingEvent.capture());
    List<LoggingEvent> events = captorLoggingEvent.getAllValues();
    String msg = "Response contains a receipt signal";
    assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:47,代码来源:PrepareResponseMessageTest.java

示例11: testDoProcessingOfTheErrors

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessingOfTheErrors() throws Exception {
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);

    MessageContext mc = new MessageContext();
    mc.setServerSide(true);
    mc.setFLOW(MessageContext.OUT_FLOW);

    try {
        mc.setEnvelope(env);
    } catch (AxisFault axisFault) {
        fail(axisFault.getMessage());
    }

    ErrorMessage errorMessage = new ErrorMessage();
    ArrayList<IEbmsError> errors = new ArrayList<>();
    EbmsError ebmsError = new EbmsError();
    ebmsError.setSeverity(IEbmsError.Severity.FAILURE);
    ebmsError.setErrorCode("some_error_code");
    errors.add(ebmsError);
    errorMessage.setErrors(errors);

    // todo We also need to test multiple errors handling
    // todo I'm going to implement this test later (TS)

    ErrorSignalElement.createElement(headerBlock, errorMessage);

    StorageManager updateManager = core.getStorageManager();
    IErrorMessageEntity errorMessageEntity =
            updateManager.storeIncomingMessageUnit(errorMessage);

    ArrayList<IErrorMessageEntity> errorMessageEntities = new ArrayList<>();
    errorMessageEntities.add(errorMessageEntity);
    mc.setProperty(MessageContextProperties.OUT_ERRORS,
            errorMessageEntities);

    // Mocking the Axis2 Operation Context
    OperationContext operationContext = mock(OperationContext.class);
    when(operationContext
            .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
            .thenReturn(mc);

    mc.setOperationContext(operationContext);

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertNotNull(invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    verify(mockAppender, atLeastOnce())
            .doAppend(captorLoggingEvent.capture());
    List<LoggingEvent> events = captorLoggingEvent.getAllValues();
    String msg = "Response does contain one error signal";
    assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:61,代码来源:PrepareResponseMessageTest.java

示例12: testDoProcessing

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
    MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);
    // Adding UserMessage from mmd
    OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);

    String msgId = "some_msg_id_01";
    UserMessage userMessage = UserMessageElement.readElement(umElement);

    String pmodeId =
            userMessage.getCollaborationInfo().getAgreement().getPModeId();
    userMessage.setPModeId(pmodeId);
    userMessage.setMessageId(msgId);

    PMode pmode = new PMode();
    pmode.setMep(EbMSConstants.ONE_WAY_MEP);
    pmode.setId(pmodeId);

    Leg leg = new Leg();
    leg.setUserMessageFlow(new UserMessageFlow());
    pmode.addLeg(leg);

    core.getPModeSet().add(pmode);

    MessageContext mc = new MessageContext();
    mc.setServerSide(true);
    mc.setFLOW(MessageContext.IN_FLOW);

    StorageManager storageManager = core.getStorageManager();

    // Setting input message property
    IUserMessageEntity userMessageEntity =
            storageManager.storeIncomingMessageUnit(userMessage);
    mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
            userMessageEntity);

    EbmsError error1 = new EbmsError();
    error1.setRefToMessageInError(userMessageEntity.getMessageId());
    error1.setErrorDetail("Some error for testing.");

    // Adding generated error
    MessageContextUtils.addGeneratedError(mc, error1);

    // Mocking the Axis2 Operation Context
    OperationContext operationContext = mock(OperationContext.class);
    when(operationContext
            .getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE))
            .thenReturn(mc);

    mc.setOperationContext(operationContext);

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    verify(mockAppender, atLeastOnce()).doAppend(captorLoggingEvent.capture());
    List<LoggingEvent> events = captorLoggingEvent.getAllValues();
    String msg1 = "This error signal should be sent as a response";
    assertTrue(TestUtils.eventContainsMsg(events, Level.DEBUG, msg1));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:68,代码来源:ProcessGeneratedErrorsTest.java

示例13: testCheckUsingAdressingOnClient

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testCheckUsingAdressingOnClient() throws Exception {
    // Need to create full description hierarchy to prevent NullPointerExceptions
    AxisOperation axisOperation = new OutInAxisOperation(new QName("Temp"));
    AxisService axisService = new AxisService("Temp");
    AxisConfiguration axisConfiguration = new AxisConfiguration();
    axisService.addOperation(axisOperation);
    axisConfiguration.addService(axisService);
    ConfigurationContext configurationContext = new ConfigurationContext(axisConfiguration);

    // Make addressing required using the same property as the AddressingConfigurator on the request
    MessageContext request = configurationContext.createMessageContext();
    request.setProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER, AddressingConstants.ADDRESSING_REQUIRED);
    
    // Create a response to invoke the in handler on        
    MessageContext response = configurationContext.createMessageContext();

    // Link the response to the request message context using the context hierarchy
    ServiceGroupContext serviceGroupContext = configurationContext.createServiceGroupContext(axisService.getAxisServiceGroup());
    ServiceContext serviceContext = serviceGroupContext.getServiceContext(axisService);
    OperationContext opContext = axisOperation.findOperationContext(request, serviceContext);
    axisOperation.registerOperationContext(request, opContext);
    request.setServiceContext(serviceContext);
    response.setServiceContext(serviceContext);
    request.setOperationContext(opContext);
    response.setOperationContext(opContext);
    
    // Invoke the in handler for a response message without addressing headers
    response.setEnvelope(TestUtil.getSOAPEnvelope("addressingDisabledTest.xml"));
    inHandler.invoke(response);
    
    // Check an exception is thrown by the validation handler because the client
    // requires addressing but the response message does not have addressing headers
    try {
        validationHandler.invoke(response);
        fail("An AxisFault should have been thrown due to the absence of addressing headers.");
    } catch (AxisFault axisFault) {
        // Confirm this is the correct fault
        assertEquals("Wrong fault code",
                     new QName(Final.FAULT_ADDRESSING_HEADER_REQUIRED),
                     axisFault.getFaultCode());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:43,代码来源:AddressingValidationHandlerTest.java

示例14: invoke

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
     * @param msgctx
     * @throws org.apache.axis2.AxisFault
     * @noinspection MethodReturnOfConcreteClass
     */
    public InvocationResponse invoke(MessageContext msgctx) throws AxisFault {
        InvocationResponse response = InvocationResponse.CONTINUE;
        
        // first check we can dispatch using the relates to
        if (msgctx.getRelatesTo() != null) {
            String relatesTo = msgctx.getRelatesTo().getValue();

            if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
                log.debug(msgctx.getLogIDString() + " " + Messages.getMessage("checkingrelatesto",
                                                                              relatesTo));
            }
            if (relatesTo != null && !"".equals(relatesTo) && (msgctx.getOperationContext()==null)) {
                OperationContext operationContext =
                        msgctx.getConfigurationContext()
                                .getOperationContext(relatesTo);

                if (operationContext != null) //noinspection TodoComment
                {
//                    if(operationContext.isComplete()){
//                        // If the dispatch happens because of the RelatesTo and the mep is complete
//                        // we should throw a more descriptive fault.
//                        throw new AxisFault(Messages.getMessage("duplicaterelatesto",relatesTo));
//                    }
                    msgctx.setAxisOperation(operationContext.getAxisOperation());
                    msgctx.setAxisMessage(operationContext.getAxisOperation().getMessage(
                                                                WSDLConstants.MESSAGE_LABEL_IN_VALUE));
                    msgctx.setOperationContext(operationContext);
                    msgctx.setServiceContext((ServiceContext) operationContext.getParent());
                    msgctx.setAxisService(
                            ((ServiceContext) operationContext.getParent()).getAxisService());

                    // TODO : Is this necessary here?
                    msgctx.getAxisOperation().registerMessageContext(msgctx, operationContext);

                    msgctx.setServiceGroupContextId(
                            ((ServiceGroupContext) msgctx.getServiceContext().getParent()).getId());

                    if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
                        log.debug(msgctx.getLogIDString() +
                                " Dispatched successfully on the RelatesTo. operation=" +
                                operationContext.getAxisOperation());
                    }
                }
            }
        }
        //Else we will try to dispatch based on the WS-A Action
        else {
            response = super.invoke(msgctx);
            Object flag = msgctx.getLocalProperty(IS_ADDR_INFO_ALREADY_PROCESSED);
            if (log.isTraceEnabled()) {
                log.trace("invoke: IS_ADDR_INFO_ALREADY_PROCESSED=" + flag);
            }

            if (JavaUtils.isTrueExplicitly(flag)) {
                // If no AxisOperation has been found at the end of the dispatch phase and addressing
                // is in use we should throw an ActionNotSupported Fault, unless we've been told
                // not to do this check (by Synapse, for instance)
                if (JavaUtils.isTrue(msgctx.getProperty(ADDR_VALIDATE_ACTION), true)) {
                    checkAction(msgctx);
                }
            }
        }
        
        return response;
    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:71,代码来源:AddressingBasedDispatcher.java

示例15: createResponseMessageContext

import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
 * Creates a new 'response' message context based on a 'request' message context
 * Only deals with properties/fields that are the same for both 'normal' and fault responses.
 *
 * @param inMessageContext context for which the response will be created
 * @return response message context for the given in message context
 * @throws org.apache.axis2.AxisFault error in creating the response message context
 */
private static MessageContext createResponseMessageContext(MessageContext inMessageContext)
        throws AxisFault {
    MessageContext newmsgCtx =
            inMessageContext.getConfigurationContext().createMessageContext();

    newmsgCtx.setSessionContext(inMessageContext.getSessionContext());
    newmsgCtx.setTransportIn(inMessageContext.getTransportIn());
    newmsgCtx.setTransportOut(inMessageContext.getTransportOut());
    newmsgCtx.setServerSide(inMessageContext.isServerSide());
    newmsgCtx.setProperty(MessageContext.IN_MESSAGE_CONTEXT, inMessageContext);

    // TODO: Should this be specifying (or defaulting to) the "response" relationshipType??
    newmsgCtx.addRelatesTo(new RelatesTo(inMessageContext.getOptions().getMessageId()));

    newmsgCtx.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                          inMessageContext.getProperty(
                                  AddressingConstants.WS_ADDRESSING_VERSION));
    newmsgCtx.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
                          inMessageContext.getProperty(
                                  AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES));

    newmsgCtx.setProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME,
                          inMessageContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME));
    newmsgCtx.setProperty(Constants.AXIS_BINDING_OPERATION,
                          inMessageContext.getProperty(Constants.AXIS_BINDING_OPERATION));

    // Setting the charater set encoding
    newmsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
                          inMessageContext.getProperty(
                                  Constants.Configuration.CHARACTER_SET_ENCODING));
    //Setting the message type property
    newmsgCtx.setProperty(Constants.Configuration.MESSAGE_TYPE,
                          inMessageContext.getProperty(Constants.Configuration.MESSAGE_TYPE));
    newmsgCtx.setDoingREST(inMessageContext.isDoingREST());

    newmsgCtx.setOperationContext(inMessageContext.getOperationContext());

    newmsgCtx.setProperty(MessageContext.TRANSPORT_OUT,
                          inMessageContext.getProperty(MessageContext.TRANSPORT_OUT));
    newmsgCtx.setProperty(Constants.OUT_TRANSPORT_INFO,
                          inMessageContext.getProperty(Constants.OUT_TRANSPORT_INFO));

    handleCorrelationID(inMessageContext,newmsgCtx);
    return newmsgCtx;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:54,代码来源:MessageContextBuilder.java


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