Search in sources :

Example 86 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project wso2-synapse by wso2.

the class FIXTransportListenerTest method testFIXTransportListenerInit.

@Test
public void testFIXTransportListenerInit() throws Exception {
    AxisService axisService = new AxisService("testFIXService");
    axisService.addParameter(new Parameter(FIXConstants.FIX_ACCEPTOR_CONFIG_URL_PARAM, "/sample/path/Mock.cfg"));
    axisService.addParameter(new Parameter(FIXConstants.FIX_INITIATOR_CONFIG_URL_PARAM, "/sample/path/Mock2.cfg"));
    ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
    TransportDescriptionFactory transportDescriptionFactory = new TransportDescriptionFactory() {

        @Override
        public TransportOutDescription createTransportOutDescription() throws Exception {
            TransportOutDescription trpOutDesc = new TransportOutDescription("fix");
            trpOutDesc.setSender(new FIXTransportSender());
            return trpOutDesc;
        }

        @Override
        public TransportInDescription createTransportInDescription() throws Exception {
            TransportInDescription trpInDesc = new TransportInDescription("fix");
            trpInDesc.setReceiver(new FIXTransportListener());
            return trpInDesc;
        }
    };
    TransportInDescription transportInDescription = null;
    try {
        transportInDescription = transportDescriptionFactory.createTransportInDescription();
    } catch (Exception e) {
        logger.error(e);
        Assert.fail("Error occurred while creating transport in description");
    }
    FIXTransportListener listner = new FIXTransportListener();
    listner.init(cfgCtx, transportInDescription);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter) TransportInDescription(org.apache.axis2.description.TransportInDescription) TransportDescriptionFactory(org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory) TransportOutDescription(org.apache.axis2.description.TransportOutDescription) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 87 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project pentaho-platform by pentaho.

the class AxisUtil method createService.

/**
 * Create a web service from a web service wrapper. The concrete subclass providers the wrappers via
 * getWebServiceWrappers()
 *
 * @param wrapper
 *          The wrapper
 * @return
 * @throws AxisFault
 */
public static AxisService createService(IServiceConfig ws, AxisConfiguration axisConfig) throws AxisFault {
    Class<?> serviceClass = ws.getServiceClass();
    String serviceName = ws.getId();
    if (axisConfig.getService(serviceName) != null) {
        axisConfig.removeService(serviceName);
    }
    AxisService axisService = createService(serviceClass.getName(), axisConfig, serviceClass.getClassLoader());
    axisService.setName(serviceName);
    axisService.setDocumentation(ws.getDescription());
    return axisService;
}
Also used : AxisService(org.apache.axis2.description.AxisService)

Example 88 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project pentaho-platform by pentaho.

the class AxisUtil method createService.

@SuppressWarnings("unchecked")
private static AxisService createService(String implClass, AxisConfiguration axisConfig, ClassLoader loader) throws AxisFault {
    try {
        HashMap messageReciverMap = new HashMap();
        // $NON-NLS-1$
        Class inOnlyMessageReceiver = Loader.loadClass("org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
        MessageReceiver messageReceiver = (MessageReceiver) inOnlyMessageReceiver.newInstance();
        messageReciverMap.put(WSDL2Constants.MEP_URI_IN_ONLY, messageReceiver);
        // $NON-NLS-1$
        Class inoutMessageReceiver = Loader.loadClass("org.apache.axis2.rpc.receivers.RPCMessageReceiver");
        MessageReceiver inOutmessageReceiver = (MessageReceiver) inoutMessageReceiver.newInstance();
        messageReciverMap.put(WSDL2Constants.MEP_URI_IN_OUT, inOutmessageReceiver);
        messageReciverMap.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY, inOutmessageReceiver);
        return AxisService.createService(implClass, axisConfig, messageReciverMap, null, null, loader);
    } catch (Exception e) {
        throw AxisFault.makeFault(e);
    }
}
Also used : HashMap(java.util.HashMap) MessageReceiver(org.apache.axis2.engine.MessageReceiver)

Example 89 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project pentaho-platform by pentaho.

the class AxisUtil method createServiceWsdl.

/**
 * Creates the WSDL for an Axis service
 *
 * @param axisService
 * @param wrapper
 * @throws Exception
 */
public static void createServiceWsdl(AxisService axisService, IServiceConfig wsDef, AxisConfiguration axisConfig) throws Exception {
    // specific that we are generating the WSDL
    Parameter useOriginalwsdl = new Parameter();
    // $NON-NLS-1$
    useOriginalwsdl.setName("useOriginalwsdl");
    // $NON-NLS-1$
    useOriginalwsdl.setValue("true");
    axisService.addParameter(useOriginalwsdl);
    // get the WSDL generation and make it a parameter
    Definition wsdlDefn = AxisUtil.getWsdlDefinition(axisConfig, wsDef);
    Parameter wsdl = new Parameter();
    wsdl.setName(WSDLConstants.WSDL_4_J_DEFINITION);
    wsdl.setValue(wsdlDefn);
    // add the WSDL parameter to the service
    axisService.addParameter(wsdl);
}
Also used : Definition(javax.wsdl.Definition) Parameter(org.apache.axis2.description.Parameter)

Example 90 with AxisConfiguration

use of org.apache.axis2.engine.AxisConfiguration in project pentaho-platform by pentaho.

the class AxisServiceExecutor method createServiceContent.

@Override
public void createServiceContent(AxisService axisService, String operationName, AxisConfiguration axisConfiguration, ConfigurationContext context, OutputStream out) throws Exception {
    // $NON-NLS-1$
    IParameterProvider pathParams = parameterProviders.get("path");
    // get the HTTP objects from the 'path' parameter provider
    // $NON-NLS-1$
    HttpServletRequest request = (HttpServletRequest) pathParams.getParameter("httprequest");
    @SuppressWarnings("unchecked") Enumeration names = request.getParameterNames();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        if (name.equalsIgnoreCase("wsdl")) {
            // $NON-NLS-1$
            axisService.printWSDL(out, AxisUtil.getWebServiceExecuteUrl());
            return;
        }
    }
    // $NON-NLS-1$
    HttpServletResponse response = (HttpServletResponse) pathParams.getParameter("httpresponse");
    // $NON-NLS-1$
    ServletConfig servletConfig = (ServletConfig) pathParams.getParameter("servletconfig");
    // create a service group and group context for this service
    AxisServiceGroup axisServiceGroup = new AxisServiceGroup(context.getAxisConfiguration());
    axisServiceGroup.addService(axisService);
    ServiceGroupContext serviceGroupContext = new ServiceGroupContext(context, axisServiceGroup);
    // create a service context
    ServiceContext serviceContext = serviceGroupContext.getServiceContext(axisService);
    // get an operation by name, if possible
    AxisOperation axisOperation = axisService.getOperationByAction(operationName);
    OperationContext operationContext = serviceContext.createOperationContext(axisOperation);
    // create an object to hook into Axis and give it everything we have
    AxisServletHooks hooks = new AxisServletHooks();
    hooks.setContext(context);
    hooks.setServletConfig(servletConfig);
    hooks.setConfiguration(axisConfiguration);
    hooks.initContextRoot(request);
    hooks.setAxisService(axisService);
    hooks.setAxisOperation(axisOperation);
    hooks.setOperationContext(operationContext);
    hooks.setServiceContext(serviceContext);
    hooks.setAxisOperation(axisOperation);
    hooks.setOperationContext(operationContext);
    // now execute the operation
    if (request != null && response != null) {
        try {
            PentahoSessionHolder.setSession(userSession);
            String method = request.getMethod();
            if ("GET".equalsIgnoreCase(method)) {
                // $NON-NLS-1$
                hooks.handleGet(method, request, response);
            } else if ("POST".equalsIgnoreCase(request.getMethod())) {
                // $NON-NLS-1$
                hooks.handlePost(method, request, response);
            } else if ("PUT".equalsIgnoreCase(request.getMethod())) {
                // $NON-NLS-1$
                hooks.handlePut(method, request, response);
            }
        } catch (Exception e) {
            processAxisFault(hooks.getMessageContext(), out, e);
            // $NON-NLS-1$
            error(Messages.getInstance().getErrorString("RunService.ERROR_0001_ERROR_DURING_EXECUTION"), e);
        }
    }
}
Also used : OperationContext(org.apache.axis2.context.OperationContext) Enumeration(java.util.Enumeration) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceContext(org.apache.axis2.context.ServiceContext) ServletConfig(javax.servlet.ServletConfig) HttpServletResponse(javax.servlet.http.HttpServletResponse) AxisServiceGroup(org.apache.axis2.description.AxisServiceGroup) HttpServletRequest(javax.servlet.http.HttpServletRequest) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) AxisServletHooks(org.pentaho.platform.plugin.services.webservices.AxisServletHooks)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)211 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)122 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)95 Test (org.junit.Test)68 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)65 Parameter (org.apache.axis2.description.Parameter)62 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)62 OMElement (org.apache.axiom.om.OMElement)40 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)35 AxisService (org.apache.axis2.description.AxisService)33 DeploymentEngine (org.apache.axis2.deployment.DeploymentEngine)32 MessageContext (org.apache.synapse.MessageContext)32 AxisFault (org.apache.axis2.AxisFault)31 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)28 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)21 DeploymentException (org.apache.axis2.deployment.DeploymentException)20 SynapseException (org.apache.synapse.SynapseException)20 IOException (java.io.IOException)19 XMLStreamException (javax.xml.stream.XMLStreamException)16 File (java.io.File)15