Search in sources :

Example 1 with AxisOperation

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

the class AdminActions method updateServiceParameters.

@Action(name = "updateServiceParameters", post = true)
public Redirect updateServiceParameters(HttpServletRequest request) throws AxisFault {
    String serviceName = request.getParameter("axisService");
    AxisService service = configContext.getAxisConfiguration().getService(serviceName);
    if (service != null) {
        for (Parameter parameter : service.getParameters()) {
            String para = request.getParameter(serviceName + "_" + parameter.getName());
            service.addParameter(new Parameter(parameter.getName(), para));
        }
        for (Iterator<AxisOperation> iterator = service.getOperations(); iterator.hasNext(); ) {
            AxisOperation axisOperation = iterator.next();
            String op_name = axisOperation.getName().getLocalPart();
            for (Parameter parameter : axisOperation.getParameters()) {
                String para = request.getParameter(op_name + "_" + parameter.getName());
                axisOperation.addParameter(new Parameter(parameter.getName(), para));
            }
        }
    }
    return new Redirect(EDIT_SERVICE_PARAMETERS).withStatus(true, "Parameters Changed Successfully.").withParameter("axisService", serviceName);
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter)

Example 2 with AxisOperation

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

the class AdminActions method editServiceParameters.

@Action(name = EDIT_SERVICE_PARAMETERS)
public View editServiceParameters(HttpServletRequest req) throws AxisFault {
    String serviceName = req.getParameter("axisService");
    AxisService service = configContext.getAxisConfiguration().getServiceForActivation(serviceName);
    if (service.isActive()) {
        if (serviceName != null) {
            req.getSession().setAttribute(Constants.SERVICE, configContext.getAxisConfiguration().getService(serviceName));
        }
        req.setAttribute("serviceName", serviceName);
        req.setAttribute("parameters", getParameters(service));
        Map<String, Map<String, String>> operations = new TreeMap<String, Map<String, String>>();
        for (Iterator<AxisOperation> it = service.getOperations(); it.hasNext(); ) {
            AxisOperation operation = it.next();
            operations.put(operation.getName().getLocalPart(), getParameters(operation));
        }
        req.setAttribute("operations", operations);
    } else {
        req.setAttribute("status", "Service " + serviceName + " is not an active service" + ". \n Only parameters of active services can be edited.");
    }
    return new View("editServiceParameters.jsp");
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 3 with AxisOperation

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

the class TCPEchoRawXMLTest method testEchoXMLSyncMC.

public void testEchoXMLSyncMC() throws Exception {
    AxisOperation opdesc = new OutInAxisOperation(new QName("echoOMElement"));
    Options options = new Options();
    options.setTo(targetEPR);
    options.setAction(operationName.getLocalPart());
    options.setTransportInProtocol(Constants.TRANSPORT_TCP);
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
    OMElement method = fac.createOMElement("echoOMElement", omNs);
    OMElement value = fac.createOMElement("myValue", omNs);
    value.setText("Isaac Asimov, The Foundation Trilogy");
    method.addChild(value);
    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope envelope = factory.getDefaultEnvelope();
    envelope.getBody().addChild(method);
    MessageContext requestContext = new MessageContext();
    requestContext.setConfigurationContext(configContext);
    requestContext.setAxisService(clientService);
    requestContext.setAxisOperation(opdesc);
    requestContext.setEnvelope(envelope);
    ServiceClient sender = new ServiceClient(configContext, clientService);
    sender.setOptions(options);
    OperationClient opClient = sender.createClient(new QName("echoOMElement"));
    opClient.addMessageContext(requestContext);
    opClient.setOptions(options);
    opClient.execute(true);
    MessageContext response = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
    SOAPEnvelope env = response.getEnvelope();
    assertNotNull(env);
    env.getBody().serialize(StAXUtils.createXMLStreamWriter(System.out));
    sender.cleanup();
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) Options(org.apache.axis2.client.Options) OperationClient(org.apache.axis2.client.OperationClient) OMNamespace(org.apache.axiom.om.OMNamespace) OutInAxisOperation(org.apache.axis2.description.OutInAxisOperation) AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) ServiceClient(org.apache.axis2.client.ServiceClient) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) MessageContext(org.apache.axis2.context.MessageContext) OutInAxisOperation(org.apache.axis2.description.OutInAxisOperation) SOAPFactory(org.apache.axiom.soap.SOAPFactory)

Example 4 with AxisOperation

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

the class XMPPSender method prepareOperationList.

/**
 * Prepares a list of service names deployed in current runtime
 * @param msgCtx
 * @return
 */
private static String prepareOperationList(MessageContext msgCtx, String chatMessage) {
    StringBuffer sb = new StringBuffer();
    // extract service name
    String serviceName = chatMessage.replace("getOperations", "");
    serviceName = serviceName.replaceAll(" ", "");
    if (log.isDebugEnabled()) {
        log.debug("Finding operations for service :" + serviceName);
    }
    try {
        AxisService service = msgCtx.getConfigurationContext().getAxisConfiguration().getService(serviceName);
        Iterator itrOperations = service.getOperations();
        int index = 1;
        while (itrOperations.hasNext()) {
            AxisOperation operation = (AxisOperation) itrOperations.next();
            String parameterList = getParameterListForOperation(operation);
            sb.append(index + "." + operation.getName().getLocalPart() + "(" + parameterList + ")" + "\n");
            index++;
        }
    } catch (AxisFault e) {
        log.error("Error occurred while retreiving AxisService : " + serviceName, e);
        sb.append("Error occurred while retrieving operations for service : " + serviceName);
    }
    return sb.toString();
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) Iterator(java.util.Iterator)

Example 5 with AxisOperation

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

the class XMPPPacketListener method createSOAPEnvelopeForRawMessage.

/**
 * Creates a SOAP envelope using details found in chat message.
 * @param msgCtx
 * @param chatMessage
 * @return
 */
private SOAPEnvelope createSOAPEnvelopeForRawMessage(MessageContext msgCtx, String chatMessage) throws AxisFault {
    // TODO : need to add error handling logic
    String callRemoved = chatMessage.replaceFirst("call", "");
    // extract Service name
    String serviceName = callRemoved.trim().substring(0, callRemoved.indexOf(":") - 1);
    String operationName = callRemoved.trim().substring(callRemoved.indexOf(":"), callRemoved.indexOf("(") - 1);
    // Extract parameters from IM message
    String parameterList = callRemoved.trim().substring(callRemoved.indexOf("("), callRemoved.trim().length() - 1);
    StringTokenizer st = new StringTokenizer(parameterList, ",");
    MultipleEntryHashMap parameterMap = new MultipleEntryHashMap();
    while (st.hasMoreTokens()) {
        String token = st.nextToken();
        String name = token.substring(0, token.indexOf("="));
        String value = token.substring(token.indexOf("=") + 1);
        parameterMap.put(name, value);
    }
    SOAPEnvelope envelope = null;
    try {
        msgCtx.setProperty(XMPPConstants.CONTAINS_SOAP_ENVELOPE, new Boolean(true));
        if (serviceName != null && serviceName.trim().length() > 0) {
            AxisService axisService = msgCtx.getConfigurationContext().getAxisConfiguration().getService(serviceName);
            msgCtx.setAxisService(axisService);
            AxisOperation axisOperation = axisService.getOperationBySOAPAction("urn:" + operationName);
            if (axisOperation != null) {
                msgCtx.setAxisOperation(axisOperation);
            }
        }
        if (operationName != null && operationName.trim().length() > 0) {
            msgCtx.setSoapAction("urn:" + operationName);
        }
        XMPPOutTransportInfo xmppOutTransportInfo = (XMPPOutTransportInfo) msgCtx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO);
        // This should be only set for messages received via chat.
        // TODO : need to read from a constant
        xmppOutTransportInfo.setContentType("xmpp/text");
        msgCtx.setServerSide(true);
        // TODO : need to support SOAP12 as well
        SOAPFactory soapFactory = new SOAP11Factory();
        envelope = BuilderUtil.buildsoapMessage(msgCtx, parameterMap, soapFactory);
    // TODO : improve error handling & messages
    } catch (AxisFault e) {
        throw new AxisFault(e.getMessage());
    } catch (OMException e) {
        throw new AxisFault(e.getMessage());
    } catch (FactoryConfigurationError e) {
        throw new AxisFault(e.getMessage());
    }
    return envelope;
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) MultipleEntryHashMap(org.apache.axis2.util.MultipleEntryHashMap) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPFactory(org.apache.axiom.soap.SOAPFactory) StringTokenizer(java.util.StringTokenizer) SOAP11Factory(org.apache.axiom.soap.impl.llom.soap11.SOAP11Factory) OMException(org.apache.axiom.om.OMException) FactoryConfigurationError(javax.xml.parsers.FactoryConfigurationError)

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