Search in sources :

Example 1 with BindingOperation

use of javax.wsdl.BindingOperation in project tdi-studio-se by Talend.

the class ComponentBuilder method buildOperation.

private OperationInfo buildOperation(OperationInfo operationInfo, BindingOperation bindingOper) {
    Operation oper = bindingOper.getOperation();
    operationInfo.setTargetMethodName(oper.getName());
    Vector operElems = findExtensibilityElement(bindingOper.getExtensibilityElements(), "operation");
    ExtensibilityElement operElem = (ExtensibilityElement) operElems.elementAt(0);
    if (operElem != null && operElem instanceof SOAPOperation) {
        SOAPOperation soapOperation = (SOAPOperation) operElem;
        operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
    } else if (operElem != null && operElem instanceof SOAP12Operation) {
        SOAP12Operation soapOperation = (SOAP12Operation) operElem;
        operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
    }
    BindingInput bindingInput = bindingOper.getBindingInput();
    BindingOutput bindingOutput = bindingOper.getBindingOutput();
    Vector bodyElems = findExtensibilityElement(bindingInput.getExtensibilityElements(), "body");
    ExtensibilityElement bodyElem = (ExtensibilityElement) bodyElems.elementAt(0);
    if (bodyElem != null && bodyElem instanceof SOAPBody) {
        SOAPBody soapBody = (SOAPBody) bodyElem;
        List styles = soapBody.getEncodingStyles();
        String encodingStyle = null;
        if (styles != null) {
            encodingStyle = styles.get(0).toString();
        }
        if (encodingStyle == null) {
            encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
        }
        operationInfo.setEncodingStyle(encodingStyle.toString());
        operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
    } else if (bodyElem != null && bodyElem instanceof SOAP12Body) {
        SOAP12Body soapBody = (SOAP12Body) bodyElem;
        String encodingStyle = null;
        if (soapBody.getEncodingStyle() != null) {
            encodingStyle = soapBody.getEncodingStyle().toString();
        }
        if (encodingStyle == null) {
            encodingStyle = DEFAULT_SOAP_ENCODING_STYLE;
        }
        operationInfo.setEncodingStyle(encodingStyle.toString());
        operationInfo.setTargetObjectURI(soapBody.getNamespaceURI());
    }
    Input inDef = oper.getInput();
    if (inDef != null) {
        Message inMsg = inDef.getMessage();
        if (inMsg != null) {
            operationInfo.setInputMessageName(inMsg.getQName().getLocalPart());
            getParameterFromMessage(operationInfo, inMsg, 1);
            operationInfo.setInmessage(inMsg);
        }
    }
    Output outDef = oper.getOutput();
    if (outDef != null) {
        Message outMsg = outDef.getMessage();
        if (outMsg != null) {
            operationInfo.setOutputMessageName(outMsg.getQName().getLocalPart());
            getParameterFromMessage(operationInfo, outMsg, 2);
            operationInfo.setOutmessage(outMsg);
        }
    }
    return operationInfo;
}
Also used : SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) BindingOutput(javax.wsdl.BindingOutput) SOAP12Body(javax.wsdl.extensions.soap12.SOAP12Body) Message(javax.wsdl.Message) Operation(javax.wsdl.Operation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) BindingInput(javax.wsdl.BindingInput) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) SOAPBody(javax.wsdl.extensions.soap.SOAPBody) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector)

Example 2 with BindingOperation

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

the class PublishMetadataRunnable method process.

@SuppressWarnings("unchecked")
private void process(Definition wsdlDefinition, Collection<XmlFileConnectionItem> selectTables) throws Exception, CoreException {
    File tempFile = null;
    try {
        File wsdlFile = null;
        String baseUri = wsdlDefinition.getDocumentBaseURI();
        URI uri = new URI(baseUri);
        if ("file".equals(uri.getScheme())) {
            wsdlFile = new File(uri.toURL().getFile());
        } else {
            Map<String, InputStream> load = new WSDLLoader().load(baseUri, "tempWsdl" + "%d.wsdl");
            InputStream inputStream = load.get(WSDLLoader.DEFAULT_FILENAME);
            tempFile = getTempFile(inputStream);
            wsdlFile = tempFile;
        }
        if (populationUtil == null) {
            populationUtil = new WSDLPopulationUtil();
            populationUtil.loadWSDL("file://" + wsdlFile.getAbsolutePath());
        }
        final Set<QName> portTypes = new HashSet<QName>();
        final Set<QName> alreadyCreated = new HashSet<QName>();
        for (Binding binding : (Collection<Binding>) wsdlDefinition.getAllBindings().values()) {
            final QName portType = binding.getPortType().getQName();
            if (portTypes.add(portType)) {
                for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
                    Operation oper = operation.getOperation();
                    Input inDef = oper.getInput();
                    if (inDef != null) {
                        Message inMsg = inDef.getMessage();
                        if (inMsg != null) {
                            // fix for TDI-20699
                            QName parameterFromMessage = getParameterFromMessage(inMsg);
                            if (parameterFromMessage == null) {
                                continue;
                            }
                            if (alreadyCreated.add(parameterFromMessage)) {
                                XsdMetadataUtils.createMetadataFromXSD(parameterFromMessage, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                            }
                        }
                    }
                    Output outDef = oper.getOutput();
                    if (outDef != null) {
                        Message outMsg = outDef.getMessage();
                        if (outMsg != null) {
                            QName parameterFromMessage = getParameterFromMessage(outMsg);
                            if (parameterFromMessage == null) {
                                continue;
                            }
                            if (alreadyCreated.add(parameterFromMessage)) {
                                XsdMetadataUtils.createMetadataFromXSD(parameterFromMessage, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                            }
                        }
                    }
                    for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
                        Message faultMsg = fault.getMessage();
                        if (faultMsg != null) {
                            QName parameterFromMessage = getParameterFromMessage(faultMsg);
                            if (parameterFromMessage == null) {
                                continue;
                            }
                            if (alreadyCreated.add(parameterFromMessage)) {
                                XsdMetadataUtils.createMetadataFromXSD(parameterFromMessage, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        throw e;
    } finally {
        if (tempFile != null) {
            tempFile.delete();
        }
    }
}
Also used : Binding(javax.wsdl.Binding) Message(javax.wsdl.Message) InputStream(java.io.InputStream) QName(javax.xml.namespace.QName) Fault(javax.wsdl.Fault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) BindingOperation(javax.wsdl.BindingOperation) Input(javax.wsdl.Input) WSDLPopulationUtil(org.talend.repository.services.utils.WSDLPopulationUtil) Output(javax.wsdl.Output) Collection(java.util.Collection) IFile(org.eclipse.core.resources.IFile) File(java.io.File) WSDLLoader(org.talend.utils.wsdl.WSDLLoader) HashSet(java.util.HashSet)

Example 3 with BindingOperation

use of javax.wsdl.BindingOperation 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)

Example 4 with BindingOperation

use of javax.wsdl.BindingOperation in project tomee by apache.

the class JaxRpcServiceInfoBuilder method buildOperations.

private Set<QName> buildOperations(Binding binding, Class serviceEndpointInterface, boolean lightweight) throws OpenEJBException {
    Set<QName> wrappedElementQNames = new HashSet<QName>();
    for (Object op : binding.getBindingOperations()) {
        BindingOperation bindingOperation = (BindingOperation) op;
        String operationName = bindingOperation.getOperation().getName();
        if (lightweight) {
            // Lightweight mappings are solely based on the Java method
            Method method = getMethodForOperation(operationName, serviceEndpointInterface);
            // Build the operation info using the method
            LightweightOperationInfoBuilder operationInfoBuilder = new LightweightOperationInfoBuilder(bindingOperation, method);
            JaxRpcOperationInfo operationInfo = operationInfoBuilder.buildOperationInfo();
            serviceInfo.operations.add(operationInfo);
        } else {
            // Heavyweight mappings are solely based on the Java to XML mapping declarations
            ServiceEndpointMethodMapping methodMapping = getMethodMappingForOperation(operationName, serviceEndpointInterface);
            // Build the operation info using the Java to XML method mapping
            HeavyweightOperationInfoBuilder operationInfoBuilder = new HeavyweightOperationInfoBuilder(bindingOperation, methodMapping, javaWsdlMapping, schemaInfo);
            JaxRpcOperationInfo operationInfo = operationInfoBuilder.buildOperationInfo();
            serviceInfo.operations.add(operationInfo);
            // remember wrapped elements for type mapping
            Set<QName> wrappedElementQNamesForOper = operationInfoBuilder.getWrapperElementQNames();
            wrappedElementQNames.addAll(wrappedElementQNamesForOper);
        }
    }
    return wrappedElementQNames;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) QName(javax.xml.namespace.QName) ServiceEndpointMethodMapping(org.apache.openejb.jee.ServiceEndpointMethodMapping) Method(java.lang.reflect.Method) HashSet(java.util.HashSet)

Example 5 with BindingOperation

use of javax.wsdl.BindingOperation in project Activiti by Activiti.

the class WSDLImporter method importServicesAndOperations.

/**
   * Imports services and operations from the WSDL definition
   */
private void importServicesAndOperations(Definition definition) {
    for (Object serviceObject : definition.getServices().values()) {
        Service service = (Service) serviceObject;
        WSService wsService = this.importService(service);
        this.wsServices.put(this.namespace + wsService.getName(), wsService);
        Port port = (Port) service.getPorts().values().iterator().next();
        for (Object bindOperationObject : port.getBinding().getBindingOperations()) {
            BindingOperation bindOperation = (BindingOperation) bindOperationObject;
            WSOperation operation = this.processOperation(bindOperation.getOperation(), wsService);
            wsService.addOperation(operation);
            this.wsOperations.put(this.namespace + operation.getName(), operation);
        }
    }
}
Also used : BindingOperation(javax.wsdl.BindingOperation) Port(javax.wsdl.Port) Service(javax.wsdl.Service)

Aggregations

BindingOperation (javax.wsdl.BindingOperation)11 Binding (javax.wsdl.Binding)5 Port (javax.wsdl.Port)5 Collection (java.util.Collection)4 Input (javax.wsdl.Input)4 Message (javax.wsdl.Message)4 Operation (javax.wsdl.Operation)4 Output (javax.wsdl.Output)4 Service (javax.wsdl.Service)4 HashSet (java.util.HashSet)3 List (java.util.List)3 BindingInput (javax.wsdl.BindingInput)3 Fault (javax.wsdl.Fault)3 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)3 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)3 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)3 QName (javax.xml.namespace.QName)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 Vector (java.util.Vector)2