Search in sources :

Example 1 with ServiceBuilder

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

the class AxisServiceUtils method createAxisServiceBuilder.

private static WSDL11ToAxisServiceBuilder createAxisServiceBuilder(BPELProcessProxy processProxy) throws AxisFault {
    Definition wsdlDef = processProxy.getWsdlDefinition();
    QName serviceName = processProxy.getServiceName();
    String portName = processProxy.getPort();
    ProcessConf pConf = processProxy.getProcessConfiguration();
    QName pid = pConf.getProcessId();
    InputStream wsdlInStream = null;
    URI wsdlBaseURI = pConf.getBaseURI().resolve(wsdlDef.getDocumentBaseURI());
    try {
        wsdlInStream = wsdlBaseURI.toURL().openStream();
    } catch (MalformedURLException e) {
        String errMsg = "Malformed WSDL base URI.";
        handleException(pid, errMsg, e);
    } catch (IOException e) {
        String errMsg = "Error opening stream.";
        handleException(pid, errMsg, e);
    }
    WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisPatchedBuilder(wsdlInStream, serviceName, portName);
    serviceBuilder.setBaseUri(wsdlBaseURI.toString());
    serviceBuilder.setCustomResolver(new Axis2UriResolver());
    try {
        serviceBuilder.setCustomWSDLResolver(new Axis2WSDLLocator(wsdlBaseURI));
    } catch (URISyntaxException e) {
        String errorMessage = "URI syntax invalid.";
        handleException(pid, errorMessage, e);
    }
    serviceBuilder.setServerSide(true);
    return serviceBuilder;
}
Also used : Axis2UriResolver(org.wso2.carbon.bpel.core.ode.integration.axis2.Axis2UriResolver) MalformedURLException(java.net.MalformedURLException) QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) Definition(javax.wsdl.Definition) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) Axis2WSDLLocator(org.wso2.carbon.bpel.core.ode.integration.axis2.Axis2WSDLLocator)

Example 2 with ServiceBuilder

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

the class AxisServiceUtils method createAxisService.

/**
 * Build the underlying Axis Service from Service QName and Port Name of interest using given WSDL
 * for BPEL document.
 * In the current implementation we are extracting service name from the soap:address' location property.
 * But specified port may not contain soap:adress instead it may contains http:address. We need to handle that
 * situation.
 *
 * @param axisConfiguration AxisConfiguration to which we should publish the service
 * @param processProxy      BPELProcessProxy
 * @return Axis Service build using WSDL, Service and Port
 * @throws org.apache.axis2.AxisFault on error
 */
public static AxisService createAxisService(AxisConfiguration axisConfiguration, BPELProcessProxy processProxy) throws AxisFault {
    QName serviceName = processProxy.getServiceName();
    String portName = processProxy.getPort();
    Definition wsdlDefinition = processProxy.getWsdlDefinition();
    ProcessConf processConfiguration = processProxy.getProcessConfiguration();
    if (log.isDebugEnabled()) {
        log.debug("Creating AxisService: Service=" + serviceName + " port=" + portName + " WSDL=" + wsdlDefinition.getDocumentBaseURI() + " BPEL=" + processConfiguration.getBpelDocument());
    }
    WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(processProxy);
    /**
     * Need to figure out a way to handle service name extractoin. According to my perspective extracting
     * the service name from the EPR is not a good decision. But we need to handle JMS case properly.
     * I am keeping JMS handling untouched until we figureout best solution.
     */
    /* String axisServiceName = extractServiceName(processConf, wsdlServiceName, portName);*/
    AxisService axisService = populateAxisService(processProxy, axisConfiguration, serviceBuilder);
    Iterator operations = axisService.getOperations();
    BPELMessageReceiver messageRec = new BPELMessageReceiver();
    /**
     * Set the corresponding BPELService to message receivers
     */
    messageRec.setProcessProxy(processProxy);
    while (operations.hasNext()) {
        AxisOperation operation = (AxisOperation) operations.next();
        // Setting WSDLAwareMessage Receiver even if operation has a message receiver specified.
        // This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
        // is set to operations).
        operation.setMessageReceiver(messageRec);
        axisConfiguration.getPhasesInfo().setOperationPhases(operation);
    }
    /**
     * TODO: JMS Destination handling.
     */
    return axisService;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) AxisService(org.apache.axis2.description.AxisService) Definition(javax.wsdl.Definition) Iterator(java.util.Iterator) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) BPELMessageReceiver(org.wso2.carbon.bpel.core.ode.integration.axis2.receivers.BPELMessageReceiver)

Example 3 with ServiceBuilder

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

the class HumanTaskStore method createAxisService.

// Creates the AxisService object from the provided ServiceBuilder object.
private AxisService createAxisService(WSDL11ToAxisServiceBuilder serviceBuilder, HumanTaskBaseConfiguration config) throws AxisFault {
    AxisService axisService;
    axisService = serviceBuilder.populateService();
    axisService.setParent(getTenantAxisConfig());
    axisService.setWsdlFound(true);
    axisService.setCustomWsdl(true);
    // axisService.setFileName(new URL(taskConfig.getWsdlDefLocation()));
    axisService.setClassLoader(getTenantAxisConfig().getServiceClassLoader());
    Utils.setEndpointsToAllUsedBindings(axisService);
    axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true"));
    /* Setting service type to use in service management*/
    axisService.addParameter(ServerConstants.SERVICE_TYPE, "humantask");
    /* Fix for losing of security configuration  when updating human-task package*/
    axisService.addParameter(new Parameter(CarbonConstants.PRESERVE_SERVICE_HISTORY_PARAM, "true"));
    Iterator operations = axisService.getOperations();
    AxisHumanTaskMessageReceiver msgReceiver = new AxisHumanTaskMessageReceiver();
    msgReceiver.setHumanTaskEngine(HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine());
    // Setting the task configuration to the message receiver. Hence no need to search for task configuration, when
    // the actual task invocation happens, we will already have the task configuration attached to the message receiver
    // itself
    msgReceiver.setTaskBaseConfiguration(config);
    while (operations.hasNext()) {
        AxisOperation operation = (AxisOperation) operations.next();
        // Setting Message Receiver even if operation has a message receiver specified.
        // This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
        // is set to operations).
        operation.setMessageReceiver(msgReceiver);
        getTenantAxisConfig().getPhasesInfo().setOperationPhases(operation);
    }
    Set<String> exposedTransports = getTenantAxisConfig().getTransportsIn().keySet();
    // Add the transports to axis2 service by reading from the tenant transport config
    for (String transport : exposedTransports) {
        axisService.addExposedTransport(transport);
    }
    if (HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isHtCoordinationEnabled() && HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().isTaskRegistrationEnabled() && config.getConfigurationType() == HumanTaskBaseConfiguration.ConfigurationType.TASK) {
        // Only Engage coordination module in-case of Tasks. Coordination module is not required for notifications
        axisService.engageModule(getConfigContext().getAxisConfiguration().getModule("htcoordination"));
    }
    return axisService;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) AxisService(org.apache.axis2.description.AxisService) Iterator(java.util.Iterator) Parameter(org.apache.axis2.description.Parameter) AxisHumanTaskMessageReceiver(org.wso2.carbon.humantask.core.integration.AxisHumanTaskMessageReceiver)

Example 4 with ServiceBuilder

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

the class HumanTaskStore method createAxisServiceBuilder.

// Creates the AxisServiceBuilder object.
private WSDL11ToAxisServiceBuilder createAxisServiceBuilder(HumanTaskBaseConfiguration taskConfig, Definition wsdlDef) {
    WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(wsdlDef, taskConfig.getServiceName(), taskConfig.getPortName());
    String wsdlBaseURI = wsdlDef.getDocumentBaseURI();
    serviceBuilder.setBaseUri(wsdlBaseURI);
    /*we don't need custom resolvers since registry takes care of it*/
    serviceBuilder.setCustomResolver(new DefaultURIResolver());
    URI wsdlBase = null;
    try {
        wsdlBase = new URI(convertToVaildURI(wsdlBaseURI));
    } catch (Exception e) {
        String error = "Error occurred while creating AxisServiceBuilder.";
        log.error(error);
    }
    serviceBuilder.setCustomWSDLResolver(new HumanTaskWSDLLocator(wsdlBase));
    serviceBuilder.setServerSide(true);
    return serviceBuilder;
}
Also used : HumanTaskWSDLLocator(org.wso2.carbon.humantask.core.integration.HumanTaskWSDLLocator) DefaultURIResolver(org.apache.ws.commons.schema.resolver.DefaultURIResolver) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) URI(java.net.URI) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 5 with ServiceBuilder

use of org.apache.axis2.deployment.ServiceBuilder in project wso2-axis2-transports by wso2.

the class ContentTypeRuleTest method setUp.

@Override
public void setUp() throws Exception {
    AxisConfiguration axisCfg = new AxisConfiguration();
    ConfigurationContext cfgCtx = new ConfigurationContext(axisCfg);
    AxisService service = new AxisService();
    InputStream in = ContentTypeRuleTest.class.getResourceAsStream(getName() + ".xml");
    try {
        OMElement element = new StAXOMBuilder(in).getDocumentElement();
        new ServiceBuilder(cfgCtx, service).populateService(element);
    } finally {
        in.close();
    }
    ruleSet = ContentTypeRuleFactory.parse(service.getParameter("test"));
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) InputStream(java.io.InputStream) AxisService(org.apache.axis2.description.AxisService) OMElement(org.apache.axiom.om.OMElement) StAXOMBuilder(org.apache.axiom.om.impl.builder.StAXOMBuilder) ServiceBuilder(org.apache.axis2.deployment.ServiceBuilder)

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