Search in sources :

Example 6 with JAXWSMethodInvoker

use of org.apache.cxf.jaxws.JAXWSMethodInvoker in project cxf by apache.

the class ProviderServiceFactoryTest method testXMLBindingFromCode.

@Test
public void testXMLBindingFromCode() throws Exception {
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(DOMSourcePayloadProvider.class);
    bean.setBus(getBus());
    bean.setInvoker(new JAXWSMethodInvoker(new DOMSourcePayloadProvider()));
    Service service = bean.create();
    assertEquals("DOMSourcePayloadProviderService", service.getName().getLocalPart());
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    assertNotNull(intf);
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(getBus());
    svrFactory.setServiceFactory(bean);
    String address = "http://localhost:9000/test";
    svrFactory.setAddress(address);
    svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    ServerImpl server = (ServerImpl) svrFactory.create();
    assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size());
    Endpoint endpoint = server.getEndpoint();
    Binding binding = endpoint.getBinding();
    assertTrue(binding instanceof XMLBinding);
    Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/provider/sayHi.xml");
    addNamespace("j", "http://service.jaxws.cxf.apache.org/");
    assertValid("/j:sayHi", res);
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) XMLBinding(org.apache.cxf.binding.xml.XMLBinding) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) ServerImpl(org.apache.cxf.endpoint.ServerImpl) Endpoint(org.apache.cxf.endpoint.Endpoint) Node(org.w3c.dom.Node) Service(org.apache.cxf.service.Service) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) XMLBinding(org.apache.cxf.binding.xml.XMLBinding) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 7 with JAXWSMethodInvoker

use of org.apache.cxf.jaxws.JAXWSMethodInvoker in project cxf by apache.

the class ProviderServiceFactoryTest method testSAAJProviderCodeFirst.

@Test
public void testSAAJProviderCodeFirst() throws Exception {
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setServiceClass(SAAJProvider.class);
    bean.setBus(getBus());
    bean.setInvoker(new JAXWSMethodInvoker(new SAAJProvider()));
    Service service = bean.create();
    assertEquals("SAAJProviderService", service.getName().getLocalPart());
    InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
    assertNotNull(intf);
    assertEquals(1, intf.getOperations().size());
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setBus(getBus());
    svrFactory.setServiceFactory(bean);
    String address = "local://localhost:9000/test";
    svrFactory.setAddress(address);
    ServerImpl server = (ServerImpl) svrFactory.create();
    Endpoint endpoint = server.getEndpoint();
    Binding binding = endpoint.getBinding();
    assertTrue(binding instanceof SoapBinding);
    SoapBindingInfo sb = (SoapBindingInfo) endpoint.getEndpointInfo().getBinding();
    assertEquals("document", sb.getStyle());
    assertEquals(false, bean.isWrapped());
    assertEquals(1, sb.getOperations().size());
    Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml");
    addNamespace("j", "http://service.jaxws.cxf.apache.org/");
    assertValid("/s:Envelope/s:Body/j:sayHi", res);
}
Also used : Binding(org.apache.cxf.binding.Binding) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) XMLBinding(org.apache.cxf.binding.xml.XMLBinding) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) Node(org.w3c.dom.Node) Service(org.apache.cxf.service.Service) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) ServerImpl(org.apache.cxf.endpoint.ServerImpl) Endpoint(org.apache.cxf.endpoint.Endpoint) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Aggregations

JAXWSMethodInvoker (org.apache.cxf.jaxws.JAXWSMethodInvoker)7 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)6 Endpoint (org.apache.cxf.endpoint.Endpoint)5 Binding (org.apache.cxf.binding.Binding)4 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)4 XMLBinding (org.apache.cxf.binding.xml.XMLBinding)4 ServerImpl (org.apache.cxf.endpoint.ServerImpl)4 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)4 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)4 Service (org.apache.cxf.service.Service)4 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)4 Test (org.junit.Test)4 Bus (org.apache.cxf.Bus)3 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)2 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)2 Node (org.w3c.dom.Node)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 URL (java.net.URL)1 PrivilegedActionException (java.security.PrivilegedActionException)1 HashMap (java.util.HashMap)1