Search in sources :

Example 1 with CalculatorImpl

use of org.apache.cxf.calculator.CalculatorImpl 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)

Aggregations

HashMap (java.util.HashMap)1 Definition (javax.wsdl.Definition)1 WSDLWriter (javax.wsdl.xml.WSDLWriter)1 Bus (org.apache.cxf.Bus)1 CalculatorImpl (org.apache.cxf.calculator.CalculatorImpl)1 Endpoint (org.apache.cxf.endpoint.Endpoint)1 Server (org.apache.cxf.endpoint.Server)1 XPathUtils (org.apache.cxf.helpers.XPathUtils)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1 ServiceWSDLBuilder (org.apache.cxf.wsdl11.ServiceWSDLBuilder)1 Test (org.junit.Test)1 Document (org.w3c.dom.Document)1