Search in sources :

Example 1 with Output

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

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

the class WSDLMetadataProcessor method buildSoapOperation.

private void buildSoapOperation(MetadataFactory mf, BindingOperation bindingOperation) {
    Operation operation = bindingOperation.getOperation();
    // add input
    String inputXML = null;
    Input input = operation.getInput();
    if (input != null) {
        Message message = input.getMessage();
        if (message != null) {
            inputXML = message.getQName().getLocalPart();
        }
    }
    // add output
    String outXML = null;
    Output output = operation.getOutput();
    if (output != null) {
        Message message = output.getMessage();
        if (message != null) {
            outXML = message.getQName().getLocalPart();
        }
    }
    // $NON-NLS-1$
    ExtensibilityElement operationExtension = getExtensibilityElement(bindingOperation.getExtensibilityElements(), "operation");
    if (!(operationExtension instanceof SOAPOperation) && !(operationExtension instanceof SOAP12Operation)) {
        return;
    }
    if (operationExtension instanceof SOAPOperation) {
        // soap:operation
        SOAPOperation soapOperation = (SOAPOperation) operationExtension;
        String style = soapOperation.getStyle();
        if (style.equalsIgnoreCase("rpc")) {
            // $NON-NLS-1$
            LogManager.logInfo(LogConstants.CTX_CONNECTOR, WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15004, operation.getName()));
            return;
        }
    } else if (operationExtension instanceof SOAP12Operation) {
        // soap:operation
        SOAP12Operation soapOperation = (SOAP12Operation) operationExtension;
        String style = soapOperation.getStyle();
        if (style.equalsIgnoreCase("rpc")) {
            // $NON-NLS-1$
            LogManager.logInfo(LogConstants.CTX_CONNECTOR, WSExecutionFactory.UTIL.gs(WSExecutionFactory.Event.TEIID15004, operation.getName()));
            return;
        }
    }
    Procedure procedure = mf.addProcedure(operation.getName());
    procedure.setVirtual(false);
    procedure.setNameInSource(operation.getName());
    mf.addProcedureParameter(inputXML, TypeFacility.RUNTIME_NAMES.XML, Type.In, procedure);
    // $NON-NLS-1$
    ProcedureParameter param = mf.addProcedureParameter("stream", TypeFacility.RUNTIME_NAMES.BOOLEAN, Type.In, procedure);
    // $NON-NLS-1$
    param.setAnnotation("If the result should be streamed.");
    param.setNullType(NullType.Nullable);
    // $NON-NLS-1$
    param.setDefaultValue("false");
    mf.addProcedureParameter(outXML, TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, procedure);
}
Also used : ProcedureParameter(org.teiid.metadata.ProcedureParameter) Input(javax.wsdl.Input) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) Message(javax.wsdl.Message) Output(javax.wsdl.Output) Procedure(org.teiid.metadata.Procedure) Operation(javax.wsdl.Operation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) BindingOperation(javax.wsdl.BindingOperation) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 3 with Output

use of javax.wsdl.Output 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 {
    List<IFile> tempFiles = new ArrayList<IFile>();
    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.remove(WSDLLoader.DEFAULT_FILENAME);
            String name = File.createTempFile("tESBConsumer", ".wsdl").getName();
            IFile tempWsdlFile = createTempFile(name, inputStream);
            tempFiles.add(tempWsdlFile);
            wsdlFile = new File(tempWsdlFile.getLocation().toPortableString());
            // TESB-19040:save import wsdl files
            if (!load.isEmpty()) {
                for (Map.Entry<String, InputStream> importWsdl : load.entrySet()) {
                    tempFiles.add(createTempFile(importWsdl.getKey(), importWsdl.getValue()));
                }
            }
        }
        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
                            List<QName> messageParts = getMessageParts(inMsg);
                            if (messageParts.isEmpty()) {
                                continue;
                            }
                            for (QName messagePart : messageParts) {
                                if (alreadyCreated.add(messagePart)) {
                                    XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                                }
                            }
                        }
                    }
                    Output outDef = oper.getOutput();
                    if (outDef != null) {
                        Message outMsg = outDef.getMessage();
                        if (outMsg != null) {
                            List<QName> messageParts = getMessageParts(outMsg);
                            if (messageParts.isEmpty()) {
                                continue;
                            }
                            for (QName messagePart : messageParts) {
                                if (alreadyCreated.add(messagePart)) {
                                    XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                                }
                            }
                        }
                    }
                    for (Fault fault : (Collection<Fault>) oper.getFaults().values()) {
                        Message faultMsg = fault.getMessage();
                        if (faultMsg != null) {
                            List<QName> messageParts = getMessageParts(faultMsg);
                            if (messageParts.isEmpty()) {
                                continue;
                            }
                            for (QName messagePart : messageParts) {
                                if (alreadyCreated.add(messagePart)) {
                                    XsdMetadataUtils.createMetadataFromXSD(messagePart, portType.getLocalPart(), oper.getName(), selectTables, wsdlFile, populationUtil);
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        throw e;
    } finally {
        for (IFile tempFile : tempFiles) {
            tempFile.delete(true, null);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) Message(javax.wsdl.Message) ArrayList(java.util.ArrayList) Fault(javax.wsdl.Fault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) URI(java.net.URI) BindingOperation(javax.wsdl.BindingOperation) Input(javax.wsdl.Input) WSDLPopulationUtil(org.talend.repository.services.utils.WSDLPopulationUtil) Output(javax.wsdl.Output) WSDLLoader(org.talend.utils.wsdl.WSDLLoader) HashSet(java.util.HashSet) Binding(javax.wsdl.Binding) InputStream(java.io.InputStream) QName(javax.xml.namespace.QName) 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) Collection(java.util.Collection) IFile(org.eclipse.core.resources.IFile) File(java.io.File) Map(java.util.Map)

Example 4 with Output

use of javax.wsdl.Output in project carbon-apimgt by wso2.

the class WSDL11SOAPOperationExtractor method getSoapOutputParameterModel.

/**
 * Gets swagger output parameter model for a given soap operation
 *
 * @param bindingOperation soap operation
 * @return list of swagger models for the parameters
 * @throws APIMgtWSDLException
 */
private List<ModelImpl> getSoapOutputParameterModel(BindingOperation bindingOperation) throws APIMgtWSDLException {
    List<ModelImpl> outputParameterModelList = new ArrayList<>();
    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Output output = operation.getOutput();
        if (output != null) {
            Message message = output.getMessage();
            if (message != null) {
                Map map = message.getParts();
                for (Object obj : map.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            outputParameterModelList.add(parameterModelMap.get(part.getElementName().getLocalPart()));
                        } else {
                            if (part.getTypeName() != null && parameterModelMap.containsKey(part.getTypeName().getLocalPart())) {
                                outputParameterModelList.add(parameterModelMap.get(part.getTypeName().getLocalPart()));
                            } else {
                                ModelImpl model = new ModelImpl();
                                model.setType(ObjectProperty.TYPE);
                                model.setName(message.getQName().getLocalPart());
                                if (getPropertyFromDataType(part.getTypeName().getLocalPart()) instanceof RefProperty) {
                                    RefProperty property = (RefProperty) getPropertyFromDataType(part.getTypeName().getLocalPart());
                                    property.set$ref(SOAPToRESTConstants.Swagger.DEFINITIONS_ROOT + part.getTypeName().getLocalPart());
                                    model.addProperty(part.getName(), property);
                                } else {
                                    model.addProperty(part.getName(), getPropertyFromDataType(part.getTypeName().getLocalPart()));
                                }
                                parameterModelMap.put(model.getName(), model);
                                outputParameterModelList.add(model);
                            }
                        }
                    }
                }
            }
        }
    }
    return outputParameterModelList;
}
Also used : Message(javax.wsdl.Message) Part(javax.wsdl.Part) Output(javax.wsdl.Output) ArrayList(java.util.ArrayList) Operation(javax.wsdl.Operation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) WSDLOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation) ModelImpl(io.swagger.models.ModelImpl) Map(java.util.Map) HashMap(java.util.HashMap) NamedNodeMap(org.w3c.dom.NamedNodeMap) RefProperty(io.swagger.models.properties.RefProperty)

Example 5 with Output

use of javax.wsdl.Output in project cxf by apache.

the class OperationVisitor method generateOutputMessage.

public Message generateOutputMessage(Operation operation, BindingOperation bindingOperation) {
    Message msg = definition.createMessage();
    QName msgName;
    if (!mapper.isDefaultMapping()) {
        // mangle the message name
        // REVISIT, do we put in the entire scope for mangling
        msgName = new QName(definition.getTargetNamespace(), getScope().tail() + "." + operation.getName() + RESPONSE_SUFFIX);
    } else {
        msgName = new QName(definition.getTargetNamespace(), operation.getName() + RESPONSE_SUFFIX);
    }
    msg.setQName(msgName);
    msg.setUndefined(false);
    String outputName = operation.getName() + RESPONSE_SUFFIX;
    Output output = definition.createOutput();
    output.setName(outputName);
    output.setMessage(msg);
    BindingOutput bindingOutput = definition.createBindingOutput();
    bindingOutput.setName(outputName);
    bindingOperation.setBindingOutput(bindingOutput);
    operation.setOutput(output);
    definition.addMessage(msg);
    return msg;
}
Also used : BindingOutput(javax.wsdl.BindingOutput) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output)

Aggregations

Output (javax.wsdl.Output)20 Message (javax.wsdl.Message)16 Input (javax.wsdl.Input)15 Operation (javax.wsdl.Operation)14 BindingOperation (javax.wsdl.BindingOperation)10 QName (javax.xml.namespace.QName)10 Part (javax.wsdl.Part)8 BindingOutput (javax.wsdl.BindingOutput)7 BindingInput (javax.wsdl.BindingInput)6 Fault (javax.wsdl.Fault)6 PortType (javax.wsdl.PortType)6 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 Binding (javax.wsdl.Binding)4 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)4 Test (org.junit.Test)4 Collection (java.util.Collection)3 BindingFault (javax.wsdl.BindingFault)3 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)3 HashMap (java.util.HashMap)2