Search in sources :

Example 6 with AxisOperation

use of org.apache.axis2.description.AxisOperation in project wso2-axis2-transports by wso2.

the class SynchronousCallback method setInMessageContext.

public synchronized void setInMessageContext(MessageContext inMessageContext) throws AxisFault {
    // thread should have activate by the first message.
    if (!isComplete) {
        // this code is invoked only if the code use with axis2 at the client side
        // when axis2 client receive messages it waits in the sending thread until the response comes.
        // so this thread only notify the waiting thread and hence we need to build the message here.
        inMessageContext.getEnvelope().build();
        OperationContext operationContext = outMessageContext.getOperationContext();
        MessageContext msgCtx = operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        if (msgCtx == null) {
            // try to see whether there is a piggy back message context
            if (outMessageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) != null) {
                msgCtx = (MessageContext) outMessageContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE);
                msgCtx.setTransportIn(inMessageContext.getTransportIn());
                msgCtx.setTransportOut(inMessageContext.getTransportOut());
                msgCtx.setServerSide(false);
                msgCtx.setProperty(BaseConstants.MAIL_CONTENT_TYPE, inMessageContext.getProperty(BaseConstants.MAIL_CONTENT_TYPE));
                // FIXME: this class must not be transport dependent since it is used by AbstractTransportListener
                msgCtx.setIncomingTransportName(org.apache.axis2.Constants.TRANSPORT_MAIL);
                msgCtx.setEnvelope(inMessageContext.getEnvelope());
            } else {
                inMessageContext.setOperationContext(operationContext);
                inMessageContext.setServiceContext(outMessageContext.getServiceContext());
                if (!operationContext.isComplete()) {
                    operationContext.addMessageContext(inMessageContext);
                }
                AxisOperation axisOp = operationContext.getAxisOperation();
                AxisMessage inMessage = axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                inMessageContext.setAxisMessage(inMessage);
                inMessageContext.setServerSide(false);
            }
        } else {
            msgCtx.setOperationContext(operationContext);
            msgCtx.setServiceContext(outMessageContext.getServiceContext());
            AxisOperation axisOp = operationContext.getAxisOperation();
            AxisMessage inMessage = axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            msgCtx.setAxisMessage(inMessage);
            msgCtx.setTransportIn(inMessageContext.getTransportIn());
            msgCtx.setTransportOut(inMessageContext.getTransportOut());
            msgCtx.setServerSide(false);
            msgCtx.setProperty(BaseConstants.MAIL_CONTENT_TYPE, inMessageContext.getProperty(BaseConstants.MAIL_CONTENT_TYPE));
            // FIXME: this class must not be transport dependent since it is used by AbstractTransportListener
            msgCtx.setIncomingTransportName(org.apache.axis2.Constants.TRANSPORT_MAIL);
            msgCtx.setEnvelope(inMessageContext.getEnvelope());
        }
        this.inMessageContext = inMessageContext;
        isComplete = true;
        this.notifyAll();
    }
}
Also used : OperationContext(org.apache.axis2.context.OperationContext) AxisOperation(org.apache.axis2.description.AxisOperation) MessageContext(org.apache.axis2.context.MessageContext) AxisMessage(org.apache.axis2.description.AxisMessage)

Example 7 with AxisOperation

use of org.apache.axis2.description.AxisOperation in project MassBank-web by MassBank.

the class AdminActions method doEngageToOperation.

@Action(name = "doEngageToOperation", post = true)
public Redirect doEngageToOperation(HttpServletRequest request) {
    String moduleName = request.getParameter("module");
    String serviceName = request.getParameter("service");
    String operationName = request.getParameter("axisOperation");
    Redirect redirect = new Redirect(ENGAGE_TO_OPERATION).withParameter("axisService", serviceName);
    try {
        AxisOperation od = configContext.getAxisConfiguration().getService(serviceName).getOperation(new QName(operationName));
        od.engageModule(configContext.getAxisConfiguration().getModule(moduleName));
        redirect.withStatus(true, moduleName + " module engaged to the operation successfully");
    } catch (AxisFault axisFault) {
        redirect.withStatus(false, axisFault.getMessage());
    }
    return redirect;
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName)

Example 8 with AxisOperation

use of org.apache.axis2.description.AxisOperation in project MassBank-web by MassBank.

the class AdminActions method processdisengageModule.

@Action(name = "disengageModule", post = true)
public Redirect processdisengageModule(HttpServletRequest req) throws AxisFault {
    String type = req.getParameter("type");
    String serviceName = req.getParameter("serviceName");
    String moduleName = req.getParameter("module");
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
    AxisService service = axisConfiguration.getService(serviceName);
    AxisModule module = axisConfiguration.getModule(moduleName);
    if (type.equals("operation")) {
        if (service.isEngaged(module.getName()) || axisConfiguration.isEngaged(module.getName())) {
            return new Redirect(LIST_SERVICES).withStatus(false, "Can not disengage module " + moduleName + ". This module is engaged at a higher level.");
        } else {
            String opName = req.getParameter("operation");
            AxisOperation op = service.getOperation(new QName(opName));
            op.disengageModule(module);
            return new Redirect(LIST_SERVICES).withStatus(true, "Module " + moduleName + " was disengaged from " + "operation " + opName + " in service " + serviceName + ".");
        }
    } else {
        if (axisConfiguration.isEngaged(module.getName())) {
            return new Redirect(LIST_SERVICES).withStatus(false, "Can not disengage module " + moduleName + ". " + "This module is engaged at a higher level.");
        } else {
            service.disengageModule(axisConfiguration.getModule(moduleName));
            return new Redirect(LIST_SERVICES).withStatus(true, "Module " + moduleName + " was disengaged from" + " service " + serviceName + ".");
        }
    }
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) AxisService(org.apache.axis2.description.AxisService) AxisModule(org.apache.axis2.description.AxisModule)

Example 9 with AxisOperation

use of org.apache.axis2.description.AxisOperation in project wso2-axis2-transports by wso2.

the class ProtocolEndpoint method createMessageContext.

public MessageContext createMessageContext() throws AxisFault {
    MessageContext msgContext = listener.createMessageContext();
    if (service != null) {
        msgContext.setAxisService(service);
        // find the operation for the message, or default to one
        Parameter operationParam = service.getParameter(BaseConstants.OPERATION_PARAM);
        QName operationQName = (operationParam != null ? BaseUtils.getQNameFromString(operationParam.getValue()) : BaseConstants.DEFAULT_OPERATION);
        AxisOperation operation = service.getOperation(operationQName);
        if (operation != null) {
            msgContext.setAxisOperation(operation);
            msgContext.setAxisMessage(operation.getMessage(WSDL2Constants.MESSAGE_LABEL_IN));
            msgContext.setSoapAction("urn:" + operation.getName().getLocalPart());
        }
    }
    return msgContext;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) Parameter(org.apache.axis2.description.Parameter) MessageContext(org.apache.axis2.context.MessageContext)

Example 10 with AxisOperation

use of org.apache.axis2.description.AxisOperation in project wso2-axis2-transports by wso2.

the class MinConcurrencyTest method runTest.

@Override
protected void runTest() throws Throwable {
    int endpointCount = channels.length;
    int expectedConcurrency = endpointCount * messages;
    final MessageReceiver messageReceiver = new MessageReceiver() {

        public void receive(MessageContext msgContext) throws AxisFault {
            synchronized (concurrencyReachedLock) {
                concurrencyReached++;
                concurrencyReachedLock.notifyAll();
            }
            try {
                synchronized (shutdownAwaitLock) {
                    shutdownAwaitLock.wait();
                }
            } catch (InterruptedException ex) {
            }
        }
    };
    TestResourceSet[] clientResourceSets = new TestResourceSet[endpointCount];
    TestResourceSet[] endpointResourceSets = new TestResourceSet[endpointCount];
    try {
        for (int i = 0; i < endpointCount; i++) {
            TestResourceSet clientResourceSet = new TestResourceSet(getResourceSet());
            AsyncChannel channel = channels[i];
            clientResourceSet.addResource(channel);
            AxisAsyncTestClient client = new AxisAsyncTestClient(false);
            clientResourceSet.addResource(client);
            clientResourceSet.setUp();
            clientResourceSets[i] = clientResourceSet;
            TestResourceSet endpointResourceSet = new TestResourceSet(clientResourceSet);
            endpointResourceSet.addResource(new AxisTestEndpoint() {

                @Override
                protected AxisOperation createOperation() {
                    AxisOperation operation = new InOnlyAxisOperation(new QName("in"));
                    operation.setMessageReceiver(messageReceiver);
                    return operation;
                }

                @Override
                protected void onTransportError(Throwable ex) {
                // TODO Auto-generated method stub
                }
            });
            if (!preloadMessages) {
                endpointResourceSet.setUp();
                endpointResourceSets[i] = endpointResourceSet;
            }
            for (int j = 0; j < messages; j++) {
                ClientOptions options = new ClientOptions(client, new ContentType(SOAP11Constants.SOAP_11_CONTENT_TYPE), "UTF-8");
                AxisMessage message = new AxisMessage();
                message.setMessageType(SOAP11Constants.SOAP_11_CONTENT_TYPE);
                SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
                SOAPEnvelope envelope = factory.getDefaultEnvelope();
                message.setEnvelope(envelope);
                client.sendMessage(options, new ContentType(message.getMessageType()), message);
            }
            if (preloadMessages) {
                endpointResourceSet.setUp();
                endpointResourceSets[i] = endpointResourceSet;
            }
        }
        long startTime = System.currentTimeMillis();
        while (concurrencyReached < expectedConcurrency && System.currentTimeMillis() < (startTime + 5000)) {
            synchronized (concurrencyReachedLock) {
                concurrencyReachedLock.wait(5000);
            }
        }
        synchronized (shutdownAwaitLock) {
            shutdownAwaitLock.notifyAll();
        }
        if (concurrencyReached < expectedConcurrency) {
            fail("Concurrency reached is " + concurrencyReached + ", but expected " + expectedConcurrency);
        }
    } finally {
        for (int i = 0; i < endpointCount; i++) {
            if (endpointResourceSets[i] != null) {
                endpointResourceSets[i].tearDown();
            }
            if (clientResourceSets[i] != null) {
                clientResourceSets[i].tearDown();
            }
        }
    }
}
Also used : ClientOptions(org.apache.axis2.transport.testkit.client.ClientOptions) InOnlyAxisOperation(org.apache.axis2.description.InOnlyAxisOperation) AxisOperation(org.apache.axis2.description.AxisOperation) ContentType(javax.mail.internet.ContentType) QName(javax.xml.namespace.QName) AsyncChannel(org.apache.axis2.transport.testkit.channel.AsyncChannel) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) AxisTestEndpoint(org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpoint) SOAPFactory(org.apache.axiom.soap.SOAPFactory) InOnlyAxisOperation(org.apache.axis2.description.InOnlyAxisOperation) MessageReceiver(org.apache.axis2.engine.MessageReceiver) AxisTestEndpoint(org.apache.axis2.transport.testkit.axis2.endpoint.AxisTestEndpoint) AxisAsyncTestClient(org.apache.axis2.transport.testkit.axis2.client.AxisAsyncTestClient) MessageContext(org.apache.axis2.context.MessageContext) TestResourceSet(org.apache.axis2.transport.testkit.tests.TestResourceSet) AxisMessage(org.apache.axis2.transport.testkit.message.AxisMessage)

Aggregations

AxisOperation (org.apache.axis2.description.AxisOperation)12 QName (javax.xml.namespace.QName)8 AxisService (org.apache.axis2.description.AxisService)6 MessageContext (org.apache.axis2.context.MessageContext)5 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)4 AxisFault (org.apache.axis2.AxisFault)4 SOAPFactory (org.apache.axiom.soap.SOAPFactory)3 AxisMessage (org.apache.axis2.description.AxisMessage)3 Parameter (org.apache.axis2.description.Parameter)3 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 OMElement (org.apache.axiom.om.OMElement)2 Options (org.apache.axis2.client.Options)2 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)2 StringTokenizer (java.util.StringTokenizer)1 TreeMap (java.util.TreeMap)1 ContentType (javax.mail.internet.ContentType)1 FactoryConfigurationError (javax.xml.parsers.FactoryConfigurationError)1 OMException (org.apache.axiom.om.OMException)1