Search in sources :

Example 91 with Definition

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

the class WSDLToCorbaBindingTypeTest method testMultipleBindings.

@Test
public void testMultipleBindings() throws Exception {
    String fileName = getClass().getResource("/wsdl/multiplePortTypes.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.setAllBindings(true);
    Definition model = generator.generateCORBABinding();
    assertEquals("All bindings should be generated.", 2, model.getAllBindings().size());
}
Also used : Definition(javax.wsdl.Definition) Test(org.junit.Test)

Example 92 with Definition

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

the class AegisTest method testAegisBasic.

@Test
public void testAegisBasic() throws Exception {
    final String sei = org.apache.cxf.tools.fortest.aegis2ws.TestAegisSEI.class.getName();
    File wsdlFile = new File(folder.getRoot(), "aegis.wsdl");
    String[] args = new String[] { "-wsdl", "-o", wsdlFile.toString(), "-verbose", "-d", folder.getRoot().toString(), "-s", folder.getRoot().toString(), "-frontend", "jaxws", "-databinding", "aegis", "-client", "-server", sei };
    JavaToWS.main(args);
    assertTrue("wsdl is not generated", wsdlFile.exists());
    WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
    reader.setFeature("javax.wsdl.verbose", false);
    Definition def = reader.readWSDL(wsdlFile.toURI().toURL().toString());
    Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(def);
    assertValid("//xsd:element[@type='ns0:Something']", wsdl);
}
Also used : Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) File(java.io.File) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Example 93 with Definition

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

the class ServiceWSDLBuilder method build.

/**
 * Create the WSDL Definition object and return it. This function respects the
 * setting of {@link #setUseSchemaImports(boolean)}.
 * @param imports A set of schema imports to either reference as imports or read and
 * then inline.
 * @return the WSDL definition
 * @throws WSDLException
 */
public Definition build(Map<String, SchemaInfo> imports) throws WSDLException {
    Definition definition = null;
    try {
        definition = services.get(0).getProperty(WSDLServiceBuilder.WSDL_DEFINITION, Definition.class);
    } catch (ClassCastException e) {
    // ignore
    }
    if (definition == null) {
        ServiceInfo si = services.get(0);
        definition = newDefinition(si.getName(), si.getTargetNamespace());
        addNamespace(WSDLConstants.CONVENTIONAL_TNS_PREFIX, si.getTargetNamespace(), definition);
        addExtensibilityElements(definition, definition, getWSDL11Extensors(si.getDescription()));
        Collection<PortType> portTypes = new HashSet<>();
        for (ServiceInfo service : services) {
            Definition portTypeDef = definition;
            Definition orig = definition;
            if (!isSameTNS(service)) {
                portTypeDef = newDefinition(service.getInterface().getName(), service.getInterface().getName().getNamespaceURI());
                Import wsdlImport = definition.createImport();
                String tns = service.getInterface().getName().getNamespaceURI();
                wsdlImport.setDefinition(portTypeDef);
                wsdlImport.setNamespaceURI(tns);
                wsdlImport.setLocationURI(service.getInterface().getName().getLocalPart() + ".wsdl");
                definition.addImport(wsdlImport);
                addNamespace(getPrefix(tns), tns, definition);
            }
            portTypes.add(buildPortType(service.getInterface(), portTypeDef));
            if (service.getSchemas() != null && service.getSchemas().size() > 0) {
                if (!useSchemaImports) {
                    buildTypes(service.getSchemas(), imports, portTypeDef);
                } else {
                    buildTypesWithSchemaImports(service.getSchemas(), imports, portTypeDef);
                }
            }
            definition = orig;
        }
        for (ServiceInfo service : services) {
            buildBinding(definition, service.getBindings(), portTypes);
            buildService(service, definition);
        }
    }
    return definition;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) SchemaImport(javax.wsdl.extensions.schema.SchemaImport) Import(javax.wsdl.Import) Definition(javax.wsdl.Definition) PortType(javax.wsdl.PortType) HashSet(java.util.HashSet)

Example 94 with Definition

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

the class SchemaUtil method getSchemas.

public void getSchemas(final Definition def, final SchemaCollection schemaCol, List<SchemaInfo> schemas) {
    List<Definition> defList = new ArrayList<>();
    parseImports(def, defList);
    extractSchema(def, schemaCol, schemas);
    // added
    getSchemaList(def);
    Map<Definition, Definition> done = new IdentityHashMap<>();
    done.put(def, def);
    for (Definition def2 : defList) {
        if (!done.containsKey(def2)) {
            extractSchema(def2, schemaCol, schemas);
            // added
            getSchemaList(def2);
            done.put(def2, def2);
        }
    }
}
Also used : IdentityHashMap(java.util.IdentityHashMap) Definition(javax.wsdl.Definition) ArrayList(java.util.ArrayList)

Example 95 with Definition

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

the class FailoverTest method updateWsdlExtensors.

/**
 * Exchange the port number in all service addresses on the bus.
 * @param port1 current port
 * @param port2 new port
 */
private void updateWsdlExtensors(String port1, String port2) {
    try {
        Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlLocation);
        Map<?, ?> map = def.getAllServices();
        for (Object o : map.values()) {
            Service service = (Service) o;
            Map<?, ?> ports = service.getPorts();
            for (Object p : ports.values()) {
                Port port = (Port) p;
                List<?> l = port.getExtensibilityElements();
                for (Object e : l) {
                    if (e instanceof SOAPAddress) {
                        String add = ((SOAPAddress) e).getLocationURI();
                        int idx = add.indexOf(":" + port1);
                        if (idx != -1) {
                            add = add.substring(0, idx) + ":" + port2 + add.substring(idx + port1.length() + 1);
                            ((SOAPAddress) e).setLocationURI(add);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Port(javax.wsdl.Port) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) Definition(javax.wsdl.Definition) WSDLManager(org.apache.cxf.wsdl.WSDLManager) ClusteredGreeterService(org.apache.cxf.greeter_control.ClusteredGreeterService) Service(javax.wsdl.Service) ControlService(org.apache.cxf.greeter_control.ControlService) Endpoint(org.apache.cxf.endpoint.Endpoint) ConnectException(java.net.ConnectException) HTTPException(org.apache.cxf.transport.http.HTTPException)

Aggregations

Definition (javax.wsdl.Definition)226 Test (org.junit.Test)113 QName (javax.xml.namespace.QName)61 File (java.io.File)52 Document (org.w3c.dom.Document)44 Element (org.w3c.dom.Element)40 HashMap (java.util.HashMap)36 WSDLReader (javax.wsdl.xml.WSDLReader)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)31 JBossWSTest (org.jboss.wsf.test.JBossWSTest)31 Service (javax.wsdl.Service)24 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)23 URL (java.net.URL)21 ArrayList (java.util.ArrayList)21 Port (javax.wsdl.Port)21 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)21 Bus (org.apache.cxf.Bus)20 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)20 WSDLManager (org.apache.cxf.wsdl.WSDLManager)20 IOException (java.io.IOException)18