Search in sources :

Example 11 with ServiceContext

use of org.apache.axis2.context.ServiceContext 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)

Example 12 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project carbon-business-process by wso2.

the class AxisServiceUtils method getOperationClient.

public static OperationClient getOperationClient(BPELMessageContext partnerMessageContext, ConfigurationContext clientConfigCtx) throws AxisFault {
    AxisService anonymousService = AnonymousServiceFactory.getAnonymousService(partnerMessageContext.getService(), partnerMessageContext.getPort(), clientConfigCtx.getAxisConfiguration(), partnerMessageContext.getCaller());
    anonymousService.engageModule(clientConfigCtx.getAxisConfiguration().getModule("UEPModule"));
    anonymousService.getParent().addParameter(BPELConstants.HIDDEN_SERVICE_PARAM, "true");
    ServiceGroupContext sgc = new ServiceGroupContext(clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
    ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);
    // get a reference to the DYNAMIC operation of the Anonymous Axis2 service
    AxisOperation axisAnonymousOperation = anonymousService.getOperation(partnerMessageContext.isTwoWay() ? ServiceClient.ANON_OUT_IN_OP : ServiceClient.ANON_OUT_ONLY_OP);
    Options clientOptions = cloneOptions(partnerMessageContext.getInMessageContext().getOptions());
    clientOptions.setExceptionToBeThrownOnSOAPFault(false);
    /* This value doesn't overrideend point config. */
    clientOptions.setTimeOutInMilliSeconds(60000);
    return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
Also used : Options(org.apache.axis2.client.Options) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) ServiceContext(org.apache.axis2.context.ServiceContext) AxisService(org.apache.axis2.description.AxisService)

Example 13 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project carbon-business-process by wso2.

the class ServiceUtils method getOperationClient.

private static OperationClient getOperationClient(MessageContext partnerMessageContext, ConfigurationContext clientConfigCtx) throws AxisFault {
    AxisService anonymousService = AnonymousServiceFactory.getAnonymousService(Constants.registrationService, Constants.REGISTRATION_PORT, clientConfigCtx.getAxisConfiguration(), Constants.HUMANTASK_COORDINATION_MODULE_NAME);
    anonymousService.getParent().addParameter("hiddenService", "true");
    ServiceGroupContext sgc = new ServiceGroupContext(clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
    ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);
    AxisOperation axisAnonymousOperation = anonymousService.getOperation(ServiceClient.ANON_OUT_IN_OP);
    Options clientOptions = cloneOptions(partnerMessageContext.getOptions());
    clientOptions.setExceptionToBeThrownOnSOAPFault(false);
    /* This value doesn't overrideend point config. */
    clientOptions.setTimeOutInMilliSeconds(60000);
    return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
Also used : Options(org.apache.axis2.client.Options) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) ServiceContext(org.apache.axis2.context.ServiceContext) AxisService(org.apache.axis2.description.AxisService)

Example 14 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project MassBank-web by MassBank.

the class AdminActions method viewServiceContext.

@Action(name = "viewServiceContext")
public View viewServiceContext(HttpServletRequest req) throws AxisFault {
    String type = req.getParameter("TYPE");
    String sgID = req.getParameter("PID");
    String ID = req.getParameter("ID");
    ServiceGroupContext sgContext = configContext.getServiceGroupContext(sgID);
    if (sgContext != null) {
        AxisService service = sgContext.getDescription().getService(ID);
        ServiceContext serviceContext = sgContext.getServiceContext(service);
        req.setAttribute("ServiceContext", serviceContext);
        req.setAttribute("TYPE", type);
    } else {
        req.setAttribute("ServiceContext", null);
        req.setAttribute("TYPE", type);
    }
    return new View("viewServiceContext.jsp");
}
Also used : ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) ServiceContext(org.apache.axis2.context.ServiceContext) AxisService(org.apache.axis2.description.AxisService)

Example 15 with ServiceContext

use of org.apache.axis2.context.ServiceContext in project carbon-apimgt by wso2.

the class WebsocketUtil method getSynapseMessageContext.

public static MessageContext getSynapseMessageContext(String tenantDomain) throws AxisFault {
    org.apache.axis2.context.MessageContext axis2MsgCtx = createAxis2MessageContext();
    ServiceContext svcCtx = new ServiceContext();
    OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx);
    axis2MsgCtx.setServiceContext(svcCtx);
    axis2MsgCtx.setOperationContext(opCtx);
    if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
        ConfigurationContext tenantConfigCtx = TenantAxisUtils.getTenantConfigurationContext(tenantDomain, axis2MsgCtx.getConfigurationContext());
        axis2MsgCtx.setConfigurationContext(tenantConfigCtx);
        axis2MsgCtx.setProperty(MultitenantConstants.TENANT_DOMAIN, tenantDomain);
    } else {
        axis2MsgCtx.setProperty(MultitenantConstants.TENANT_DOMAIN, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    }
    return MessageContextCreatorForAxis2.getSynapseMessageContext(axis2MsgCtx);
}
Also used : OperationContext(org.apache.axis2.context.OperationContext) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) ServiceContext(org.apache.axis2.context.ServiceContext) InOutAxisOperation(org.apache.axis2.description.InOutAxisOperation)

Aggregations

ServiceContext (org.apache.axis2.context.ServiceContext)24 OperationContext (org.apache.axis2.context.OperationContext)15 InOutAxisOperation (org.apache.axis2.description.InOutAxisOperation)14 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)12 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)11 AxisService (org.apache.axis2.description.AxisService)10 MessageContext (org.apache.synapse.MessageContext)10 ServiceGroupContext (org.apache.axis2.context.ServiceGroupContext)9 AxisOperation (org.apache.axis2.description.AxisOperation)8 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)8 EndpointReference (org.apache.axis2.addressing.EndpointReference)6 Options (org.apache.axis2.client.Options)6 SynapseException (org.apache.synapse.SynapseException)6 MessageContext (org.apache.axis2.context.MessageContext)5 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)5 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)5 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)4 Test (org.junit.Test)4 Map (java.util.Map)3 QName (javax.xml.namespace.QName)3