Search in sources :

Example 6 with Input

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

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

the class WSDL11SOAPOperationExtractor method getTargetNamespace.

/**
 * Gets the target namespace given the soap binding operation
 *
 * @param bindingOperation soap operation
 * @return target name space
 */
private String getTargetNamespace(BindingOperation bindingOperation) {
    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Input input = operation.getInput();
        if (input != null) {
            Message message = input.getMessage();
            if (message != null) {
                Map partMap = message.getParts();
                for (Object obj : partMap.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            return part.getElementName().getNamespaceURI();
                        }
                    }
                }
            }
        }
    }
    return targetNamespace;
}
Also used : Input(javax.wsdl.Input) Message(javax.wsdl.Message) Part(javax.wsdl.Part) 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) Map(java.util.Map) HashMap(java.util.HashMap) NamedNodeMap(org.w3c.dom.NamedNodeMap)

Example 8 with Input

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

the class ServiceWSDLBuilderTest method testSayHiOperation.

@Test
public void testSayHiOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(), "Greeter"));
    Collection<Operation> operations = CastUtils.cast(portType.getOperations(), Operation.class);
    assertEquals(4, operations.size());
    Operation sayHi = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
    assertNotNull(sayHi);
    assertEquals(sayHi.getName(), "sayHi");
    Input input = sayHi.getInput();
    assertNotNull(input);
    assertEquals("sayHiRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("sayHiRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = sayHi.getOutput();
    assertNotNull(output);
    assertEquals("sayHiResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("sayHiResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("out", message.getPart("out").getName());
    assertEquals(0, sayHi.getFaults().size());
}
Also used : Input(javax.wsdl.Input) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) Output(javax.wsdl.Output) Operation(javax.wsdl.Operation) PortType(javax.wsdl.PortType) Test(org.junit.Test)

Example 9 with Input

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

the class ServiceWSDLBuilderTest method testGreetMeOperation.

@Test
public void testGreetMeOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(), "Greeter"));
    Operation greetMe = portType.getOperation("greetMe", "greetMeRequest", "greetMeResponse");
    assertNotNull(greetMe);
    assertEquals("greetMe", greetMe.getName());
    Input input = greetMe.getInput();
    assertNotNull(input);
    assertEquals("greetMeRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("greetMeRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = greetMe.getOutput();
    assertNotNull(output);
    assertEquals("greetMeResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("greetMeResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("out", message.getPart("out").getName());
    assertEquals(0, greetMe.getFaults().size());
}
Also used : Input(javax.wsdl.Input) Message(javax.wsdl.Message) QName(javax.xml.namespace.QName) Output(javax.wsdl.Output) Operation(javax.wsdl.Operation) PortType(javax.wsdl.PortType) Test(org.junit.Test)

Example 10 with Input

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

the class WSDLParameter method processInputParams.

private void processInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
    Input input = operation.getInput();
    if (input != null) {
        Message msg = input.getMessage();
        List<Part> parts = CastUtils.cast(msg.getOrderedParts(null));
        for (Part part : parts) {
            XmlSchemaType schemaType = null;
            boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
            if (part.getElementName() != null && !isObjectRef) {
                XmlSchemaElement el = getElement(part, xmlSchemaList);
                if (el != null) {
                    if (el.getSchemaType() != null) {
                        schemaType = el.getSchemaType();
                    }
                    QName typeName = el.getSchemaTypeName();
                    if (typeName == null) {
                        typeName = el.getQName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
                    ParamType paramtype = createParam(wsdlToCorbaBinding, "in", part.getName(), idltype);
                    if (paramtype != null) {
                        inputs.add(paramtype);
                    }
                }
            } else if (part.getTypeName() != null) {
                schemaType = getType(part, xmlSchemaList);
                QName typeName = part.getTypeName();
                if (isObjectRef) {
                    typeName = part.getElementName();
                }
                QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
                ParamType paramtype = createParam(wsdlToCorbaBinding, "in", part.getName(), idltype);
                if (paramtype != null) {
                    inputs.add(paramtype);
                }
            }
        }
    }
}
Also used : Input(javax.wsdl.Input) Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Aggregations

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