Search in sources :

Example 6 with GreeterImpl

use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.

the class GreeterTest method testEndpointValidate.

@Test
public void testEndpointValidate() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    bean.setWsdlURL(resource.toString());
    bean.setBus(bus);
    bean.setServiceClass(GreeterImpl.class);
    bean.setValidate(true);
    GreeterImpl greeter = new GreeterImpl();
    BeanInvoker invoker = new BeanInvoker(greeter);
    Service service = bean.create();
    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
    ServerFactoryBean svr = new ServerFactoryBean();
    svr.setBus(bus);
    svr.setServiceFactory(bean);
    svr.setInvoker(invoker);
    svr.create();
    Node response = invoke("http://localhost:9000/SoapContext/SoapPort", LocalTransportFactory.TRANSPORT_ID, "GreeterMessage.xml");
    assertEquals(1, greeter.getInvocationCount());
    assertNotNull(response);
    addNamespace("h", "http://apache.org/hello_world_soap_http/types");
    assertValid("/s:Envelope/s:Body", response);
    assertValid("//h:sayHiResponse", response);
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) Node(org.w3c.dom.Node) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Example 7 with GreeterImpl

use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.

the class EndpointReferenceTest method testServiceGetPortUsingEndpointReference.

/*
     * Any JAX-WS supported epr metadata MUST match the Service instances
     * ServiceName, otherwise a WebServiceExeption MUST be thrown. Any JAX-WS
     * supported epr metadata MUST match the PortName for the sei, otherwise a
     * WebServiceException MUST be thrown. If the Service instance has an
     * associated WSDL, its WSDL MUST be used to determine any binding
     * information, anyWSDL in a JAX-WS suppported epr metadata MUST be ignored.
     * If the Service instance does not have a WSDL, then any WSDL inlined in
     * the JAX-WS supported metadata of the epr MUST be used to determine
     * binding information. If there is not enough metadata in the Service
     * instance or in the epr metadata to determine a port, then a
     * WebServiceException MUST be thrown.
     */
@Test
public void testServiceGetPortUsingEndpointReference() throws Exception {
    BusFactory.setDefaultBus(getBus());
    GreeterImpl greeter1 = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        javax.xml.ws.Service s = javax.xml.ws.Service.create(new QName("http://apache.org/hello_world_soap_http", "SoapPort"));
        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        DOMSource erXML = new DOMSource(doc);
        EndpointReference endpointReference = EndpointReference.readFrom(erXML);
        WebServiceFeature[] wfs = new WebServiceFeature[] {};
        Greeter greeter = s.getPort(endpointReference, Greeter.class, wfs);
        String response = greeter.greetMe("John");
        assertEquals("Hello John", response);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceFeature(javax.xml.ws.WebServiceFeature) Test(org.junit.Test)

Example 8 with GreeterImpl

use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.

the class EndpointReferenceTest method testEndpointReferenceGetPort.

@Test
public void testEndpointReferenceGetPort() throws Exception {
    BusFactory.setDefaultBus(getBus());
    GreeterImpl greeter1 = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter1, (String) null)) {
        endpoint.publish("http://localhost:8080/test");
        InputStream is = getClass().getResourceAsStream("resources/hello_world_soap_http_infoset.xml");
        Document doc = StaxUtils.read(is);
        DOMSource erXML = new DOMSource(doc);
        EndpointReference endpointReference = EndpointReference.readFrom(erXML);
        WebServiceFeature[] wfs = new WebServiceFeature[] {};
        Greeter greeter = endpointReference.getPort(Greeter.class, wfs);
        String response = greeter.greetMe("John");
        assertEquals("Hello John", response);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) InputStream(java.io.InputStream) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceFeature(javax.xml.ws.WebServiceFeature) Document(org.w3c.dom.Document) EndpointReference(javax.xml.ws.EndpointReference) W3CEndpointReference(javax.xml.ws.wsaddressing.W3CEndpointReference) Test(org.junit.Test)

Example 9 with GreeterImpl

use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.

the class SoapFaultTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUpBus();
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    bean.setWsdlURL(resource.toString());
    bean.setBus(bus);
    bean.setServiceClass(GreeterImpl.class);
    GreeterImpl greeter = new GreeterImpl();
    BeanInvoker invoker = new BeanInvoker(greeter);
    bean.setInvoker(invoker);
    service = bean.create();
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceFactory(bean);
    svrFactory.create();
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) URL(java.net.URL) Before(org.junit.Before)

Example 10 with GreeterImpl

use of org.apache.hello_world_soap_http.GreeterImpl in project cxf by apache.

the class ManagedBusTest method testTwoSameNamedEndpoint.

@Test
public void testTwoSameNamedEndpoint() throws Exception {
    SpringBusFactory factory = new SpringBusFactory();
    Bus bus = factory.createBus();
    try {
        InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
        assertNotNull(im);
        InstrumentationManagerImpl imi = (InstrumentationManagerImpl) im;
        imi.setServer(ManagementFactory.getPlatformMBeanServer());
        imi.setEnabled(true);
        imi.init();
        Greeter greeter1 = new GreeterImpl();
        JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello");
        svrFactory.setServiceBean(greeter1);
        svrFactory.getProperties(true).put("managed.endpoint.name", "greeter1");
        svrFactory.create();
        Greeter greeter2 = new GreeterImpl();
        svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello2");
        svrFactory.setServiceBean(greeter2);
        svrFactory.getProperties(true).put("managed.endpoint.name", "greeter2");
        svrFactory.create();
        MBeanServer mbs = im.getMBeanServer();
        ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME + ":type=Bus.Service.Endpoint,*");
        Set<?> s = mbs.queryMBeans(name, null);
        assertEquals(2, s.size());
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) InstrumentationManagerImpl(org.apache.cxf.management.jmx.InstrumentationManagerImpl) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Greeter(org.apache.hello_world_soap_http.Greeter) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) Test(org.junit.Test)

Aggregations

GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)28 Test (org.junit.Test)17 URL (java.net.URL)7 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)7 InputStream (java.io.InputStream)6 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)6 Document (org.w3c.dom.Document)6 EndpointReference (javax.xml.ws.EndpointReference)5 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)5 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)5 BusException (org.apache.cxf.BusException)4 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)4 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)4 Service (org.apache.cxf.service.Service)4 QName (javax.xml.namespace.QName)3 DOMSource (javax.xml.transform.dom.DOMSource)3 WebServiceContext (javax.xml.ws.WebServiceContext)3 WebServiceFeature (javax.xml.ws.WebServiceFeature)3 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)3 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)3