Search in sources :

Example 56 with Definition

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

the class CodeFirstWSDLTest method testWSDL1.

@Test
public void testWSDL1() throws Exception {
    Definition d = createService(Hello2.class);
    QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "Hello2Service");
    javax.wsdl.Service service = d.getService(serviceName);
    assertNotNull(service);
    QName portName = new QName("http://service.jaxws.cxf.apache.org/", "Hello2Port");
    javax.wsdl.Port port = service.getPort(portName.getLocalPart());
    assertNotNull(port);
    QName portTypeName = new QName("http://service.jaxws.cxf.apache.org/", "HelloInterface");
    javax.wsdl.PortType portType = d.getPortType(portTypeName);
    assertNotNull(portType);
    assertEquals(5, portType.getOperations().size());
}
Also used : QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) Test(org.junit.Test)

Example 57 with Definition

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

the class CodeFirstWSDLTest method testOnlyRootElementOnFaultBean.

@Test
public void testOnlyRootElementOnFaultBean() throws Exception {
    // CXF-4016
    EndpointImpl ep = (EndpointImpl) Endpoint.publish("local://foo4016", new CXF4016Impl());
    ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, ep.getService().getServiceInfos().get(0));
    Definition def = wsdlBuilder.build();
    Document d = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter().getDocument(def);
    this.addNamespace("http://www.example.org/contract/DoubleIt", "tns");
    // org.apache.cxf.helpers.XMLUtils.printDOM(d);
    assertXPathEquals("//xsd:element/@ref", new QName("http://www.example.org/contract/DoubleIt", "CustomMessageBean"), d);
}
Also used : QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) WSDLManager(org.apache.cxf.wsdl.WSDLManager) Document(org.w3c.dom.Document) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) Test(org.junit.Test)

Example 58 with Definition

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

the class CodeFirstWSDLTest method testWSDL2.

@Test
public void testWSDL2() throws Exception {
    Definition d = createService(Hello3.class);
    QName serviceName = new QName("http://mynamespace.com/", "MyService");
    javax.wsdl.Service service = d.getService(serviceName);
    assertNotNull(service);
    QName portName = new QName("http://mynamespace.com/", "MyPort");
    javax.wsdl.Port port = service.getPort(portName.getLocalPart());
    assertNotNull(port);
    QName portTypeName = new QName("http://service.jaxws.cxf.apache.org/", "HelloInterface");
    javax.wsdl.PortType portType = d.getPortType(portTypeName);
    assertNotNull(portType);
    assertEquals(5, portType.getOperations().size());
}
Also used : QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) Test(org.junit.Test)

Example 59 with Definition

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

the class JaxWsServerFactoryBeanTest method testJaxwsServiceClass.

@Test
public void testJaxwsServiceClass() throws Exception {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceClass(CalculatorPortType.class);
    factory.setServiceBean(new CalculatorImpl());
    String address = "http://localhost:9001/jaxwstest";
    factory.setAddress(address);
    Server server = factory.create();
    Endpoint endpoint = server.getEndpoint();
    ServiceInfo service = endpoint.getEndpointInfo().getService();
    assertNotNull(service);
    Bus bus = factory.getBus();
    Definition def = new ServiceWSDLBuilder(bus, service).build();
    WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
    def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
    Document doc = wsdlWriter.getDocument(def);
    Map<String, String> ns = new HashMap<>();
    ns.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
    ns.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
    XPathUtils xpather = new XPathUtils(ns);
    xpather.isExist("/wsdl:definitions/wsdl:binding/soap:binding", doc, XPathConstants.NODE);
    xpather.isExist("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='add']/soap:operation", doc, XPathConstants.NODE);
    xpather.isExist("/wsdl:definitions/wsdl:service/wsdl:port[@name='add']/soap:address[@location='" + address + "']", doc, XPathConstants.NODE);
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) Definition(javax.wsdl.Definition) WSDLWriter(javax.wsdl.xml.WSDLWriter) Document(org.w3c.dom.Document) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) XPathUtils(org.apache.cxf.helpers.XPathUtils) CalculatorImpl(org.apache.cxf.calculator.CalculatorImpl) Test(org.junit.Test)

Example 60 with Definition

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

the class CodeFirstTest method testWrappedModel.

@Test
public void testWrappedModel() throws Exception {
    Definition d = createService(true);
    Document wsdl = WSDLFactory.newInstance().newWSDLWriter().getDocument(d);
    addNamespace("svc", "http://service.jaxws.cxf.apache.org");
    assertValid("/wsdl:definitions/wsdl:service[@name='HelloService']", wsdl);
    assertValid("//wsdl:port/wsdlsoap:address[@location='" + address + "']", wsdl);
    assertValid("//wsdl:portType[@name='Hello']", wsdl);
    assertValid("/wsdl:definitions/wsdl:message[@name='sayHi']" + "/wsdl:part[@element='tns:sayHi'][@name='parameters']", wsdl);
    assertValid("/wsdl:definitions/wsdl:message[@name='sayHiResponse']" + "/wsdl:part[@element='tns:sayHiResponse'][@name='parameters']", wsdl);
    assertValid("//xsd:complexType[@name='sayHi']" + "/xsd:sequence/xsd:element[@name='arg0']", wsdl);
}
Also used : Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) Test(org.junit.Test)

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