Search in sources :

Example 1 with ExtensibilityElement

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

the class ComponentBuilder method createSchemaFromTypes.

protected Vector<XmlSchema> createSchemaFromTypes(List<Definition> wsdlDefinitions) throws WSDLException {
    Vector<XmlSchema> schemas = new Vector<XmlSchema>();
    Set<String> imports = new HashSet<String>();
    org.w3c.dom.Element schemaElementt = null;
    Map importElement = null;
    List includeElement = null;
    for (Definition def : wsdlDefinitions) {
        if (def.getTypes() != null) {
            Vector schemaExtElem = findExtensibilityElement(def.getTypes().getExtensibilityElements(), "schema");
            for (int i = 0; i < schemaExtElem.size(); i++) {
                ExtensibilityElement schemaElement = (ExtensibilityElement) schemaExtElem.elementAt(i);
                if (schemaElement != null && schemaElement instanceof UnknownExtensibilityElement) {
                    schemaElementt = ((UnknownExtensibilityElement) schemaElement).getElement();
                    String documentBase = ((javax.wsdl.extensions.schema.Schema) schemaElement).getDocumentBaseURI();
                    XmlSchema schema = createschemafromtype(schemaElementt, def, documentBase);
                    if (schema != null) {
                        schemas.add(schema);
                        if (schema.getTargetNamespace() != null) {
                            schemaNames.add(schema.getTargetNamespace());
                        }
                    }
                    importElement = ((javax.wsdl.extensions.schema.Schema) schemaElement).getImports();
                    if (importElement != null && importElement.size() > 0) {
                        findImportSchema(def, schemas, importElement, imports);
                    }
                }
                if (schemaElement != null && schemaElement instanceof javax.wsdl.extensions.schema.Schema) {
                    schemaElementt = ((javax.wsdl.extensions.schema.Schema) schemaElement).getElement();
                    String documentBase = ((javax.wsdl.extensions.schema.Schema) schemaElement).getDocumentBaseURI();
                    Boolean isHaveImport = false;
                    importElement = ((javax.wsdl.extensions.schema.Schema) schemaElement).getImports();
                    if (importElement != null && importElement.size() > 0) {
                        Iterator keyIterator = importElement.keySet().iterator();
                        // }
                        if (importElement.size() > 0) {
                            isHaveImport = true;
                        }
                    // validateImportUrlPath(importElement);
                    }
                    XmlSchema schema = createschemafromtype(schemaElementt, def, documentBase);
                    if (schema != null) {
                        schemas.add(schema);
                        if (schema.getTargetNamespace() != null) {
                            schemaNames.add(schema.getTargetNamespace());
                        }
                    }
                    if (isHaveImport) {
                        findImportSchema(def, schemas, importElement, imports);
                    }
                }
            }
        }
    }
    return schemas;
}
Also used : XmlSchema(org.apache.ws.commons.schema.XmlSchema) Definition(javax.wsdl.Definition) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) XmlSchema(org.apache.ws.commons.schema.XmlSchema) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector) Map(java.util.Map) HashSet(java.util.HashSet)

Example 2 with ExtensibilityElement

use of javax.wsdl.extensions.ExtensibilityElement 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 3 with ExtensibilityElement

use of javax.wsdl.extensions.ExtensibilityElement in project tomcat by apache.

the class ServiceRefFactory method getSOAPLocation.

/**
     * @param port analyzed port
     * @return Returns the endpoint URL of the given Port
     */
private String getSOAPLocation(Port port) {
    String endpoint = null;
    @SuppressWarnings("unchecked") List<ExtensibilityElement> extensions = port.getExtensibilityElements();
    for (Iterator<ExtensibilityElement> i = extensions.iterator(); i.hasNext(); ) {
        ExtensibilityElement ext = i.next();
        if (ext instanceof SOAPAddress) {
            SOAPAddress addr = (SOAPAddress) ext;
            endpoint = addr.getLocationURI();
        }
    }
    return endpoint;
}
Also used : SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 4 with ExtensibilityElement

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

the class AllTypeDialog method initSimpleType.

private void initSimpleType() throws WSDLException, URISyntaxException {
    String url = URLValue;
    XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
    WSDLFactory wsdlFactory = WSDLFactory.newInstance();
    WSDLReader newWSDLReader = wsdlFactory.newWSDLReader();
    newWSDLReader.setFeature(com.ibm.wsdl.Constants.FEATURE_VERBOSE, false);
    URI wsdlURI = new URI(url);
    Definition definition = newWSDLReader.readWSDL(url);
    java.util.List<ExtensibilityElement> extensibilityElements = definition.getTypes().getExtensibilityElements();
    String tmpTNName = "";
    int tmpCount = 0;
    for (ExtensibilityElement el : extensibilityElements) {
        if (el instanceof Schema) {
            Schema schema = (Schema) el;
            // for bug 8674
            // set base uri for relative path in schemaLocation.
            schemaCollection.setBaseUri(schema.getDocumentBaseURI());
            if (schema.getElement().getAttributeNode("targetNamespace") == null) {
                tmpTNName = schema.getDocumentBaseURI() + "#type" + tmpCount;
                schemaCollection.read(schema.getElement(), tmpTNName);
                tmpCount++;
            } else {
                schemaCollection.read(schema.getElement());
            }
        }
    }
    Map namespaces = definition.getNamespaces();
    // System.out.println(namespaces);
    XmlSchema[] schemas = schemaCollection.getXmlSchemas();
    java.util.List<String> labelList = new ArrayList<String>();
    for (int i = 0; i < schemas.length; i++) {
        XmlSchema schema = schemas[i];
        XmlSchemaObjectTable types = schema.getSchemaTypes();
        Iterator it = types.getValues();
        while (it.hasNext()) {
            XmlSchemaType type = (XmlSchemaType) it.next();
            if (type instanceof XmlSchemaSimpleType) {
                XmlSchemaSimpleType t = (XmlSchemaSimpleType) type;
                String label = "simpletype:" + t.getName();
                if (!labelList.contains(label)) {
                    labelList.add(label);
                    labelAndNameSpaceMap.put(label, t.getQName().toString());
                }
            }
        }
    }
    allXMLSimpleTypeName = new String[labelList.size()];
    for (int i = 0; i < labelList.size(); i++) {
        allXMLSimpleTypeName[i] = labelList.get(i);
    }
}
Also used : XmlSchemaObjectTable(org.apache.ws.commons.schema.XmlSchemaObjectTable) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Schema(javax.wsdl.extensions.schema.Schema) Definition(javax.wsdl.Definition) ArrayList(java.util.ArrayList) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) URI(java.net.URI) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) WSDLFactory(javax.wsdl.factory.WSDLFactory) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 5 with ExtensibilityElement

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

the class ComponentBuilder method buildOperations.

private List buildOperations(Binding binding) {
    List operationInfos = new ArrayList();
    List operations = binding.getBindingOperations();
    if (operations != null && !operations.isEmpty()) {
        Vector soapBindingElems = findExtensibilityElement(binding.getExtensibilityElements(), "binding");
        // default
        String style = "document";
        ExtensibilityElement soapBindingElem = (ExtensibilityElement) soapBindingElems.elementAt(0);
        if (soapBindingElem != null && soapBindingElem instanceof SOAPBinding) {
            SOAPBinding soapBinding = (SOAPBinding) soapBindingElem;
            style = soapBinding.getStyle();
        } else if (soapBindingElem != null && soapBindingElem instanceof SOAP12Binding) {
            SOAP12Binding soapBinding = (SOAP12Binding) soapBindingElem;
            style = soapBinding.getStyle();
        }
        Iterator opIter = operations.iterator();
        while (opIter.hasNext()) {
            alldExtendtion.clear();
            BindingOperation oper = (BindingOperation) opIter.next();
            Vector operElems = findExtensibilityElement(oper.getExtensibilityElements(), "operation");
            ExtensibilityElement operElem = (ExtensibilityElement) operElems.elementAt(0);
            if (operElem != null && operElem instanceof SOAPOperation) {
                OperationInfo operationInfo = new OperationInfo(style);
                buildOperation(operationInfo, oper);
                operationInfos.add(operationInfo);
            } else if (operElem != null && operElem instanceof SOAP12Operation) {
                OperationInfo operationInfo = new OperationInfo(style);
                buildOperation(operationInfo, oper);
                operationInfos.add(operationInfo);
            }
        }
    }
    return operationInfos;
}
Also used : OperationInfo(org.talend.designer.webservice.ws.wsdlinfo.OperationInfo) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Aggregations

ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)6 ArrayList (java.util.ArrayList)5 Iterator (java.util.Iterator)4 List (java.util.List)4 Vector (java.util.Vector)4 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)4 Map (java.util.Map)3 BindingOperation (javax.wsdl.BindingOperation)2 Definition (javax.wsdl.Definition)2 SOAPAddress (javax.wsdl.extensions.soap.SOAPAddress)2 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)2 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)2 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)2 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)2 XmlSchema (org.apache.ws.commons.schema.XmlSchema)2 OperationInfo (org.talend.designer.webservice.ws.wsdlinfo.OperationInfo)2 URI (java.net.URI)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Binding (javax.wsdl.Binding)1