Search in sources :

Example 21 with Service

use of javax.wsdl.Service in project carbon-business-process by wso2.

the class PeopleActivity method getBinding.

public Binding getBinding() throws FaultException {
    Service serviceDef = hiWSDL.getService(serviceName);
    if (serviceDef == null) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service definition is not available for service " + serviceName);
    }
    Port port = serviceDef.getPort(getServicePort());
    if (port == null) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service port is not available for service " + serviceName + " and port " + getServicePort());
    }
    Binding binding = port.getBinding();
    if (binding == null) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service binding is not available for service " + serviceName + " and port " + getServicePort());
    }
    return binding;
}
Also used : HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) FaultException(org.apache.ode.bpel.common.FaultException) Port(javax.wsdl.Port) Service(javax.wsdl.Service)

Example 22 with Service

use of javax.wsdl.Service in project carbon-business-process by wso2.

the class PeopleActivity method deriveServiceEPR.

private void deriveServiceEPR(DeploymentUnitDir du, ExtensionContext extensionContext) throws FaultException {
    DeployDocument deployDocument = du.getDeploymentDescriptor();
    BpelRuntimeContext runTimeContext = extensionContext.getInternalInstance();
    // TODO neeed to extend ExtentionContext
    OProcess oProcess = runTimeContext.getProcessModel();
    TDeployment.Process hiProcess = null;
    List<TDeployment.Process> processList = deployDocument.getDeploy().getProcessList();
    for (TDeployment.Process process : processList) {
        if (process.getName().equals(oProcess.getQName())) {
            hiProcess = process;
            break;
        }
    }
    if (hiProcess == null) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Related process: " + oProcess.getQName() + " not found");
    }
    List<TInvoke> tInvokeList = hiProcess.getInvokeList();
    for (TInvoke tInvoke : tInvokeList) {
        if (tInvoke.getPartnerLink().equals(partnerLinkName)) {
            serviceName = tInvoke.getService().getName();
            servicePort = tInvoke.getService().getPort();
            break;
        }
    }
    if (serviceName == null || servicePort == null) {
        log.error("service and port for human interaction is not found in the deploy.xml");
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service or port for human interaction is not found in the deploy.xml");
    }
    // get the callback information for the TASK
    if (activityType.equals(InteractionType.TASK)) {
        List<TProvide> tProvideList = hiProcess.getProvideList();
        for (TProvide tProvide : tProvideList) {
            if (tProvide.getPartnerLink().equals(partnerLinkName)) {
                callbackServiceName = tProvide.getService().getName();
                callbackServicePort = tProvide.getService().getPort();
                break;
            }
        }
        if (callbackServiceName == null || callbackServicePort == null) {
            throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service or port for human task callback is not found in the deploy.xml");
        }
    }
    hiWSDL = du.getDefinitionForService(serviceName);
    Service service = hiWSDL.getService(serviceName);
    Port port = service.getPort(servicePort);
    List extList = port.getExtensibilityElements();
    for (Object extEle : extList) {
        if (extEle instanceof SOAPAddressImpl) {
            SOAPAddressImpl soapAddress = (SOAPAddressImpl) extEle;
            serviceURI = soapAddress.getLocationURI();
            break;
        }
    }
    if (serviceURI == null) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service URI is not available");
    }
}
Also used : SOAPAddressImpl(com.ibm.wsdl.extensions.soap.SOAPAddressImpl) OProcess(org.apache.ode.bpel.o.OProcess) Port(javax.wsdl.Port) Service(javax.wsdl.Service) OProcess(org.apache.ode.bpel.o.OProcess) TDeployment(org.apache.ode.bpel.dd.TDeployment) TInvoke(org.apache.ode.bpel.dd.TInvoke) FaultException(org.apache.ode.bpel.common.FaultException) DeployDocument(org.apache.ode.bpel.dd.DeployDocument) BpelRuntimeContext(org.apache.ode.bpel.runtime.BpelRuntimeContext) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) TProvide(org.apache.ode.bpel.dd.TProvide)

Example 23 with Service

use of javax.wsdl.Service in project carbon-business-process by wso2.

the class HTRenderingApiImpl method setTaskOutput.

public SetTaskOutputResponse setTaskOutput(URI taskIdentifier, SetOutputValuesType values) throws SetTaskOutputFaultException {
    // Retrieve task information
    TaskDAO htTaskDAO;
    try {
        htTaskDAO = getTaskDAO(taskIdentifier);
    } catch (Exception e) {
        log.error("Error occurred while retrieving task data", e);
        throw new SetTaskOutputFaultException(e);
    }
    QName taskName = QName.valueOf(htTaskDAO.getName());
    // Check hash map for output message template
    Element outputMsgTemplate = outputTemplates.get(taskName);
    if (outputMsgTemplate == null) {
        try {
            // generate output message template
            int tenantID = CarbonContext.getThreadLocalCarbonContext().getTenantId();
            HumanTaskBaseConfiguration htConf = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantID).getTaskConfiguration(taskName);
            TaskConfiguration taskConf = (TaskConfiguration) htConf;
            // retrieve response binding
            Service callbackService = (Service) taskConf.getResponseWSDL().getServices().get(taskConf.getCallbackServiceName());
            Port callbackPort = (Port) callbackService.getPorts().get(taskConf.getCallbackPortName());
            String callbackBinding = callbackPort.getBinding().getQName().getLocalPart();
            outputMsgTemplate = createSoapTemplate(taskConf.getResponseWSDL().getDocumentBaseURI(), taskConf.getResponsePortType().getLocalPart(), taskConf.getResponseOperation(), callbackBinding);
        } catch (Exception e) {
            log.error("Error occurred while output message template generation", e);
            throw new SetTaskOutputFaultException("Unable to generate output message", e);
        }
        // add to the template HashMap
        if (outputMsgTemplate != null) {
            outputTemplates.put(taskName, outputMsgTemplate);
        } else {
            log.error("Unable to create output message template");
            throw new SetTaskOutputFaultException("Unable to generate output message");
        }
    }
    // update template with new values
    try {
        // TODO improve this section with caching
        QName renderingType = new QName(htRenderingNS, "output", "wso2");
        String outputRenderings = (String) taskOps.getRendering(taskIdentifier, renderingType);
        SetOutputvalueType[] valueSet = values.getValue();
        if (outputRenderings != null && valueSet.length > 0) {
            Element outputRenderingsElement = DOMUtils.stringToDOM(outputRenderings);
            // update elements in the template to create output xml
            for (int i = 0; i < valueSet.length; i++) {
                Element outElement = getOutputElementById(valueSet[i].getId(), outputRenderingsElement);
                if (outElement != null) {
                    outputMsgTemplate = updateXmlByXpath(outputMsgTemplate, outElement.getElementsByTagNameNS(htRenderingNS, "xpath").item(0).getTextContent(), valueSet[i].getString(), outputRenderingsElement.getOwnerDocument());
                }
            }
        } else {
            log.error("Retrieving output renderings failed");
            throw new SetTaskOutputFaultException("Retrieving output renderings failed");
        }
        // TODO what is this NCName?
        taskOps.setOutput(taskIdentifier, new NCName("message"), DOMUtils.domToString(outputMsgTemplate));
    } catch (IllegalArgumentFault illegalArgumentFault) {
        // Error occurred while retrieving HT renderings and set output message
        throw new SetTaskOutputFaultException(illegalArgumentFault);
    } catch (SAXException e) {
        log.error("Error occured while parsing output renderings", e);
        throw new SetTaskOutputFaultException("Response message generation failed");
    } catch (XPathExpressionException e) {
        // Error occured while updating elements in the template to create output xml
        log.error("XPath evaluation failed", e);
        throw new SetTaskOutputFaultException("Internal Error Occurred");
    } catch (Exception e) {
        // Error occurred while updating template with new values
        log.error("Error occurred while updating template with new values", e);
        throw new SetTaskOutputFaultException("Internal Error Occurred");
    }
    SetTaskOutputResponse response = new SetTaskOutputResponse();
    response.setSuccess(true);
    return response;
}
Also used : QName(javax.xml.namespace.QName) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Element(org.w3c.dom.Element) Port(javax.wsdl.Port) SetTaskOutputResponse(org.wso2.carbon.humantask.rendering.api.SetTaskOutputResponse) TaskConfiguration(org.wso2.carbon.humantask.core.store.TaskConfiguration) Service(javax.wsdl.Service) HumanTaskBaseConfiguration(org.wso2.carbon.humantask.core.store.HumanTaskBaseConfiguration) XPathExpressionException(javax.xml.xpath.XPathExpressionException) SetTaskOutputFaultException(org.wso2.carbon.humantask.rendering.api.SetTaskOutputFaultException) GetRenderingsFaultException(org.wso2.carbon.humantask.rendering.api.GetRenderingsFaultException) SAXException(org.xml.sax.SAXException) CompleteTaskFaultException(org.wso2.carbon.humantask.rendering.api.CompleteTaskFaultException) IOException(java.io.IOException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) NCName(org.apache.axis2.databinding.types.NCName) SAXException(org.xml.sax.SAXException) SetOutputvalueType(org.wso2.carbon.humantask.rendering.api.SetOutputvalueType) TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO) IllegalArgumentFault(org.wso2.carbon.humantask.client.api.IllegalArgumentFault) SetTaskOutputFaultException(org.wso2.carbon.humantask.rendering.api.SetTaskOutputFaultException)

Example 24 with Service

use of javax.wsdl.Service in project teiid by teiid.

the class WSDLMetadataProcessor method process.

@Override
public void process(MetadataFactory mf, WSConnection connection) throws TranslatorException {
    if (this.importWSDL && connection == null) {
        throw new TranslatorException(WSExecutionFactory.UTIL.gs(Event.TEIID15007, WSExecutionFactory.UTIL.gs(Event.TEIID15007)));
    }
    if (!importWSDL || connection.getWsdl() == null) {
        return;
    }
    String wsdl = connection.getWsdl().toString();
    try {
        WSDLFactory wsdlFactory = WSDLFactory.newInstance();
        WSDLReader reader = wsdlFactory.newWSDLReader();
        this.definition = reader.readWSDL(wsdl);
    } catch (WSDLException e) {
        throw new TranslatorException(e);
    }
    Map<QName, Service> services = this.definition.getServices();
    if (services == null || services.isEmpty()) {
        throw new TranslatorException(WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15001, connection.getServiceQName()));
    }
    Service service = services.get(connection.getServiceQName());
    if (service == null) {
        throw new TranslatorException(WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15001, connection.getServiceQName()));
    }
    Map<String, Port> ports = service.getPorts();
    Port port = ports.get(connection.getPortQName().getLocalPart());
    if (port == null) {
        throw new TranslatorException(WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15002, connection.getPortQName(), connection.getServiceQName()));
    }
    getPortMetadata(mf, port);
}
Also used : WSDLFactory(javax.wsdl.factory.WSDLFactory) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) Service(javax.wsdl.Service) TranslatorException(org.teiid.translator.TranslatorException) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 25 with Service

use of javax.wsdl.Service in project tesb-studio-se by Talend.

the class WSDLUtils method isOperationInBinding.

public static boolean isOperationInBinding(Definition definition, String portTypeName, String operationName) throws CoreException {
    Collection<?> services = definition.getServices().values();
    for (Object s : services) {
        Service service = (Service) s;
        Collection<?> ports = service.getPorts().values();
        for (Object p : ports) {
            Port port = (Port) p;
            Binding binding = port.getBinding();
            if (binding == null) {
                continue;
            }
            PortType portType = binding.getPortType();
            if (portType == null || !portTypeName.equals(portType.getQName().getLocalPart())) {
                continue;
            }
            List<?> bindingOperations = binding.getBindingOperations();
            for (Object o : bindingOperations) {
                BindingOperation bo = (BindingOperation) o;
                if (operationName.equals(bo.getName())) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) ServicePort(org.talend.repository.services.model.services.ServicePort) Port(javax.wsdl.Port) Service(javax.wsdl.Service) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PortType(javax.wsdl.PortType)

Aggregations

Service (javax.wsdl.Service)53 Port (javax.wsdl.Port)37 QName (javax.xml.namespace.QName)28 Definition (javax.wsdl.Definition)21 Test (org.junit.Test)16 Binding (javax.wsdl.Binding)12 File (java.io.File)10 HashMap (java.util.HashMap)10 Map (java.util.Map)8 BindingOperation (javax.wsdl.BindingOperation)8 WSDLReader (javax.wsdl.xml.WSDLReader)8 SOAPAddress (javax.wsdl.extensions.soap.SOAPAddress)7 ToolException (org.apache.cxf.tools.common.ToolException)6 List (java.util.List)5 Operation (javax.wsdl.Operation)5 Part (javax.wsdl.Part)5 PortType (javax.wsdl.PortType)5 WSDLFactory (javax.wsdl.factory.WSDLFactory)5 Bus (org.apache.cxf.Bus)5 URI (java.net.URI)4