Search in sources :

Example 6 with ServiceBuilder

use of org.apache.axis2.deployment.ServiceBuilder in project carbon-business-process by wso2.

the class ServiceConfigurationUtil method configureService.

public static void configureService(AxisService axisService, EndpointConfiguration endpointConf, ConfigurationContext configCtx) throws AxisFault {
    if (endpointConf != null && endpointConf.isServiceDescriptionAvailable() && StringUtils.isNotEmpty(endpointConf.getServiceDescriptionLocation())) {
        OMElement documentEle = getServiceElement(endpointConf);
        if (documentEle != null) {
            if (log.isDebugEnabled()) {
                log.debug("Configuring service " + axisService.getName() + " using: " + endpointConf.getServiceDescriptionLocation());
            }
            ServiceBuilder builder = new ServiceBuilder(configCtx, axisService);
            Iterator itr = documentEle.getChildElements();
            while (itr.hasNext()) {
                OMElement serviceEle = (OMElement) itr.next();
                if (serviceEle.getLocalName().toLowerCase().equals("service")) {
                    if (serviceEle.getAttribute(new QName("name")) != null && serviceEle.getAttribute(new QName("name")).getAttributeValue().equals(axisService.getName())) {
                        builder.populateService(serviceEle);
                        // This is a hack to avoid security configurations get persisted when we configure using
                        // services.xml file or policy.xml file BPEL package. But this should be fix at the
                        // Carbon Persistence manager.
                        Parameter param = new Parameter(BusinessProcessConstants.CONFIGURED_USING_BPEL_PKG_CONFIG_FILES, "true");
                        axisService.addParameter(param);
                    }
                }
            }
        }
    }
}
Also used : QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) Parameter(org.apache.axis2.description.Parameter) OMElement(org.apache.axiom.om.OMElement) ServiceBuilder(org.apache.axis2.deployment.ServiceBuilder)

Example 7 with ServiceBuilder

use of org.apache.axis2.deployment.ServiceBuilder in project carbon-business-process by wso2.

the class HumanTaskStore method validateServiceCreationForTaskConfig.

/**
 * When wsdl errors are there in the package, we use a dummy service creation step to validate all required parts
 * are available in the wsdl
 * @param taskConfig Task configuration object for this task package
 * @throws HumanTaskDeploymentException HumanTaskDeployment Exception is thrown when an error happens
 */
private void validateServiceCreationForTaskConfig(HumanTaskBaseConfiguration taskConfig) throws HumanTaskDeploymentException {
    try {
        WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(taskConfig, taskConfig.getWSDL());
        serviceBuilder.populateService();
    } catch (AxisFault e) {
        String errorMsg = "Error validating wsdl " + e.getMessage();
        throw new HumanTaskDeploymentException(errorMsg, e);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)

Example 8 with ServiceBuilder

use of org.apache.axis2.deployment.ServiceBuilder in project carbon-business-process by wso2.

the class HumanTaskStore method deploy.

private void deploy(HumanTaskBaseConfiguration taskConfig) throws HumanTaskDeploymentException {
    if (taskConfig != null) {
        /**
         * Creating AxisService for HI
         */
        if (log.isDebugEnabled()) {
            log.debug("Deploying task " + taskConfig.getName());
        }
        AxisService axisService;
        Definition wsdlDef = taskConfig.getWSDL();
        if (taskConfig instanceof TaskConfiguration) {
            // to get the task id as response
            wsdlDef.getPortType(taskConfig.getPortType()).getOperation(taskConfig.getOperation(), null, null).setStyle(OperationType.REQUEST_RESPONSE);
        } else {
            // ONE_WAY no feed back for NOTIFICATIONS
            wsdlDef.getPortType(taskConfig.getPortType()).getOperation(taskConfig.getOperation(), null, null).setStyle(OperationType.ONE_WAY);
        }
        WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(taskConfig, wsdlDef);
        try {
            axisService = createAxisService(serviceBuilder, taskConfig);
            ServiceConfigurationUtil.configureService(axisService, taskConfig.getEndpointConfiguration(taskConfig.getServiceName().getLocalPart(), taskConfig.getPortName()), getConfigContext());
            ArrayList<AxisService> serviceList = new ArrayList<AxisService>();
            serviceList.add(axisService);
            DeploymentEngine.addServiceGroup(createServiceGroupForService(axisService), serviceList, null, null, getTenantAxisConfig());
            if (log.isDebugEnabled()) {
                log.debug(" Published axis2 service " + axisService.getName() + " for task " + taskConfig.getName());
            }
        } catch (AxisFault axisFault) {
            String errMsg = "Error populating the service";
            log.error(errMsg);
            throw new HumanTaskDeploymentException(errMsg, axisFault);
        }
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisService(org.apache.axis2.description.AxisService) Definition(javax.wsdl.Definition) ArrayList(java.util.ArrayList) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)

Example 9 with ServiceBuilder

use of org.apache.axis2.deployment.ServiceBuilder in project carbon-business-process by wso2.

the class AxisServiceUtils method populateAxisService.

private static AxisService populateAxisService(BPELProcessProxy processProxy, AxisConfiguration axisConfiguration, WSDL11ToAxisServiceBuilder serviceBuilder) throws AxisFault {
    ProcessConf pConf = processProxy.getProcessConfiguration();
    AxisService axisService = serviceBuilder.populateService();
    axisService.setParent(axisConfiguration);
    axisService.setWsdlFound(true);
    axisService.setCustomWsdl(true);
    axisService.setClassLoader(axisConfiguration.getServiceClassLoader());
    URL wsdlUrl = null;
    for (File file : pConf.getFiles()) {
        if (file.getAbsolutePath().indexOf(processProxy.getWsdlDefinition().getDocumentBaseURI()) > 0) {
            try {
                wsdlUrl = file.toURI().toURL();
            } catch (MalformedURLException e) {
                String errorMessage = "Cannot convert File URI to URL.";
                handleException(pConf.getProcessId(), errorMessage, e);
            }
        }
    }
    if (wsdlUrl != null) {
        axisService.setFileName(wsdlUrl);
    }
    Utils.setEndpointsToAllUsedBindings(axisService);
    axisService.addParameter(new Parameter("useOriginalwsdl", "true"));
    axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true"));
    axisService.addParameter(new Parameter("setEndpointsToAllUsedBindings", "true"));
    /* Setting service type to use in service management*/
    axisService.addParameter(ServerConstants.SERVICE_TYPE, "bpel");
    /* Process ID as a service parameter to use with process try-it*/
    axisService.addParameter(BPELConstants.PROCESS_ID, pConf.getProcessId());
    /* Fix for losing of security configuration  when updating BPEL package*/
    axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
    return axisService;
}
Also used : MalformedURLException(java.net.MalformedURLException) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) AxisService(org.apache.axis2.description.AxisService) Parameter(org.apache.axis2.description.Parameter) File(java.io.File) URL(java.net.URL)

Aggregations

AxisService (org.apache.axis2.description.AxisService)5 WSDL11ToAxisServiceBuilder (org.apache.axis2.description.WSDL11ToAxisServiceBuilder)5 Iterator (java.util.Iterator)3 Definition (javax.wsdl.Definition)3 QName (javax.xml.namespace.QName)3 Parameter (org.apache.axis2.description.Parameter)3 ProcessConf (org.apache.ode.bpel.iapi.ProcessConf)3 HumanTaskDeploymentException (org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException)3 InputStream (java.io.InputStream)2 MalformedURLException (java.net.MalformedURLException)2 URI (java.net.URI)2 OMElement (org.apache.axiom.om.OMElement)2 AxisFault (org.apache.axis2.AxisFault)2 ServiceBuilder (org.apache.axis2.deployment.ServiceBuilder)2 AxisOperation (org.apache.axis2.description.AxisOperation)2 File (java.io.File)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1