Search in sources :

Example 61 with Definition

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

the class AbstractAegisTest method getWSDLDocuments.

protected Collection<Document> getWSDLDocuments(String string) throws WSDLException {
    WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
    Collection<Document> docs = new ArrayList<>();
    Definition definition = getWSDLDefinition(string);
    if (definition == null) {
        return null;
    }
    docs.add(writer.getDocument(definition));
    for (Import wsdlImport : getImports(definition)) {
        docs.add(writer.getDocument(wsdlImport.getDefinition()));
    }
    return docs;
}
Also used : Import(javax.wsdl.Import) ArrayList(java.util.ArrayList) Definition(javax.wsdl.Definition) WSDLWriter(javax.wsdl.xml.WSDLWriter) Document(org.w3c.dom.Document)

Example 62 with Definition

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

the class ServiceImpl method initializePorts.

private void initializePorts() {
    try {
        Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
        javax.wsdl.Service serv = def.getService(serviceName);
        if (serv == null) {
            throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
        }
        Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
        for (Port port : wsdlports.values()) {
            QName name = new QName(serviceName.getNamespaceURI(), port.getName());
            String address = null;
            String bindingID = null;
            List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
            if (!extensions.isEmpty()) {
                ExtensibilityElement e = extensions.get(0);
                if (e instanceof SoapBinding) {
                    bindingID = SOAPBinding.SOAP11HTTP_BINDING;
                } else if (e instanceof SOAP12Binding) {
                    bindingID = SOAPBinding.SOAP12HTTP_BINDING;
                } else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
                    bindingID = SOAPBinding.SOAP11HTTP_BINDING;
                }
            }
            extensions = CastUtils.cast(port.getExtensibilityElements());
            if (!extensions.isEmpty()) {
                ExtensibilityElement e = extensions.get(0);
                if (e instanceof SoapAddress) {
                    address = ((SoapAddress) e).getLocationURI();
                } else if (e instanceof AddressType) {
                    address = ((AddressType) e).getLocation();
                } else if (e instanceof SOAP12Address) {
                    address = ((SOAP12Address) e).getLocationURI();
                } else if (e instanceof SOAPAddress) {
                    address = ((SOAPAddress) e).getLocationURI();
                } else if (e instanceof HTTPAddress) {
                    address = ((HTTPAddress) e).getLocationURI();
                }
            }
            addPort(name, bindingID, address);
        }
    } catch (WebServiceException e) {
        throw e;
    } catch (Throwable e) {
        if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, e.getLocalizedMessage(), e);
        }
        WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
        Service service = sf.create();
        for (ServiceInfo si : service.getServiceInfos()) {
            for (EndpointInfo ei : si.getEndpoints()) {
                String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
                addPort(ei.getName(), bindingID, ei.getAddress());
            }
        }
    }
}
Also used : HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) Port(javax.wsdl.Port) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) SOAP12Address(javax.wsdl.extensions.soap12.SOAP12Address) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) UncheckedException(org.apache.cxf.common.i18n.UncheckedException) SoapAddress(org.apache.cxf.binding.soap.wsdl.extensions.SoapAddress) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) WSDLManager(org.apache.cxf.wsdl.WSDLManager) AddressType(org.apache.cxf.wsdl.http.AddressType)

Example 63 with Definition

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

the class ParameterMappingTest method testNamedParameter.

@Test
public void testNamedParameter() throws Exception {
    Node doc = getWSDLDocument("ArrayService");
    Definition def = getWSDLDefinition("ArrayService");
    StringWriter sink = new StringWriter();
    WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sink);
    assertValid("/wsdl:definitions/wsdl:types/" + "xsd:schema[@targetNamespace= 'http://services.aegis.cxf.apache.org']" + "/xsd:complexType[@name='verifyCustomParamName']" + "/xsd:sequence" + "/xsd:element[@name='custom']", doc);
}
Also used : StringWriter(java.io.StringWriter) Node(org.w3c.dom.Node) Definition(javax.wsdl.Definition) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 64 with Definition

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

the class NamespaceConfusionTest method testNameNamespace.

@Test
public void testNameNamespace() throws Exception {
    org.w3c.dom.Document doc = getWSDLDocument("NameServiceImpl");
    Element rootElement = doc.getDocumentElement();
    Definition def = getWSDLDefinition("NameServiceImpl");
    StringWriter sink = new StringWriter();
    WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sink);
    NodeList aonNodes = assertValid("//xsd:complexType[@name='ArrayOfName']/xsd:sequence/xsd:element", doc);
    Element arrayOfNameElement = (Element) aonNodes.item(0);
    String typename = arrayOfNameElement.getAttribute("type");
    String prefix = typename.split(":")[0];
    String uri = getNamespaceForPrefix(rootElement, arrayOfNameElement, prefix);
    assertNotNull(uri);
    AegisType nameType = tm.getTypeCreator().createType(Name.class);
    QName tmQname = nameType.getSchemaType();
    assertEquals(tmQname.getNamespaceURI(), uri);
}
Also used : StringWriter(java.io.StringWriter) AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Definition(javax.wsdl.Definition) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 65 with Definition

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

the class ExplicitPrefixTest method testOnePrefix.

@Test
public void testOnePrefix() throws Exception {
    Map<String, String> mappings = new HashMap<>();
    mappings.put(URN_AEGIS_NAMESPACE_TEST, AEGIS_TEST_NAMESPACE_PREFIX_XYZZY);
    ServiceAndMapping serviceAndMapping = setupService(NameServiceImpl.class, mappings);
    Definition def = getWSDLDefinition("NameServiceImpl");
    StringWriter wsdlSink = new StringWriter();
    WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, wsdlSink);
    org.w3c.dom.Document wsdlDoc = getWSDLDocument("NameServiceImpl");
    Element rootElement = wsdlDoc.getDocumentElement();
    addNamespace(AEGIS_TEST_NAMESPACE_PREFIX_XYZZY, URN_AEGIS_NAMESPACE_TEST);
    assertXPathEquals("//namespace::xyzzy", URN_AEGIS_NAMESPACE_TEST, rootElement);
    Element nameSchema = (Element) assertValid("//xsd:schema[@targetNamespace='urn:aegis:namespace:test']", rootElement).item(0);
    Map<String, String> namePrefixes = getNodeNamespaceDeclarations(nameSchema);
    // there should be no TNS prefix, since the TNS namespace is explicitly
    // xyzzy.
    assertFalse(namePrefixes.containsKey("tns"));
    Element serviceSchema = (Element) assertValid("//xsd:schema[@targetNamespace='http://impl.namespaces.aegis.cxf.apache.org']", rootElement).item(0);
    Map<String, String> servicePrefixes = getNodeNamespaceDeclarations(serviceSchema);
    String testPrefix = lookupPrefix(servicePrefixes, URN_AEGIS_NAMESPACE_TEST);
    assertEquals(AEGIS_TEST_NAMESPACE_PREFIX_XYZZY, testPrefix);
    serviceAndMapping.getServer().destroy();
}
Also used : StringWriter(java.io.StringWriter) HashMap(java.util.HashMap) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

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