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);
}
}
}
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);
}
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);
}
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");
}
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);
}
Aggregations