Java Code Examples for org.apache.cxf.jaxws.JaxWsServerFactoryBean#setServiceClass()

The following examples show how to use org.apache.cxf.jaxws.JaxWsServerFactoryBean#setServiceClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DualOutServiceTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWSDL() throws Exception {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(DualOutService.class);
    sf.setAddress("local://DualOutService");
    sf.setBus(getBus());
    setupAegis(sf);
    sf.create();

    Document wsdl = getWSDLDocument("DualOutService");
    assertNotNull(wsdl);

    addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);

    assertValid(
                "//xsd:complexType[@name='getValuesResponse']//xsd:element"
                + "[@name='return'][@type='xsd:string']",
                wsdl);
    assertValid(
                "//xsd:complexType[@name='getValuesResponse']//xsd:element"
                + "[@name='return1'][@type='xsd:string']",
                wsdl);
}
 
Example 2
Source File: IntegrationBaseTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected Server createRemoteResource(ResourceManager manager) {
    ResourceRemote implementor = new ResourceRemote();
    implementor.setManager(manager);
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();

    Map<String, Object> props = factory.getProperties(true);
    props.put("jaxb.additionalContextClasses",
            org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType.class);
    factory.setProperties(props);

    factory.setBus(bus);
    factory.setServiceClass(ResourceFactory.class);
    factory.setAddress(RESOURCE_REMOTE_MANAGER_ADDRESS);
    factory.setServiceBean(implementor);
    return factory.create();
}
 
Example 3
Source File: StudentTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testReturnMap() throws Exception {

    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(StudentService.class);
    sf.setServiceBean(new StudentServiceImpl());
    sf.setAddress("local://StudentService");
    setupAegis(sf);
    Server server = sf.create();
    server.start();

    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://StudentService");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());

    StudentService clientInterface = proxyFac.create(StudentService.class);
    Map<Long, Student> fullMap = clientInterface.getStudentsMap();
    assertNotNull(fullMap);
    Student one = fullMap.get(Long.valueOf(1));
    assertNotNull(one);
    assertEquals("Student1", one.getName());

    Map<String, ?> wildMap = clientInterface.getWildcardMap();
    assertEquals("valuestring", wildMap.get("keystring"));
}
 
Example 4
Source File: TestUtils.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static Server createResourceFactory(ResourceManager resourceManager, String port, String port2) {
    ResourceFactoryImpl resourceFactory = new ResourceFactoryImpl();
    resourceFactory.setResourceResolver(
            new MyResourceResolver("http://localhost:" + port + "/ResourceStudents",
                                   resourceManager,
                                   "http://localhost:" + port2 + "/ResourceTeachers"));
    resourceFactory.getResourceTypeIdentifiers().add(
            new XSDResourceTypeIdentifier(
                    new StreamSource(TestUtils.class.getResourceAsStream("/schema/studentCreate.xsd")),
                    new XSLTResourceTransformer(
                            new StreamSource(TestUtils.class.getResourceAsStream("/xslt/studentCreate.xsl")))));
    resourceFactory.getResourceTypeIdentifiers().add(
            new XSDResourceTypeIdentifier(
                    new StreamSource(TestUtils.class.getResourceAsStream("/schema/teacherCreateBasic.xsd")),
                    new XSLTResourceTransformer(
                            new StreamSource(
                                    TestUtils.class.getResourceAsStream("/xslt/teacherCreateBasic.xsl")))));
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceClass(org.apache.cxf.ws.transfer.resourcefactory.ResourceFactory.class);
    factory.setServiceBean(resourceFactory);
    factory.setAddress("http://localhost:" + port + "/ResourceFactory");

    return factory.create();
}
 
Example 5
Source File: ProviderServiceFactoryTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testSourceMessageProviderCodeFirst() throws Exception {
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(SourceMessageProvider.class);
    svrFactory.setBus(getBus());
    svrFactory.setServiceBean(new SourceMessageProvider());
    String address = "local://localhost:9000/test";
    svrFactory.setAddress(address);

    svrFactory.create();

    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);
}
 
Example 6
Source File: AbstractAegisTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected Server createJaxwsService(Class<?> serviceClass,
                                    Object serviceBean, String address, QName name) {
    if (address == null) {
        address = serviceClass.getSimpleName();
    }
    JaxWsServiceFactoryBean sf = new JaxWsServiceFactoryBean();
    sf.setDataBinding(new AegisDatabinding());
    JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean();
    serverFactoryBean.setServiceClass(serviceClass);

    if (serviceBean != null) {
        serverFactoryBean.setServiceBean(serviceBean);
    }

    serverFactoryBean.setAddress("local://" + address);

    serverFactoryBean.setServiceFactory(sf);
    if (name != null) {
        serverFactoryBean.setEndpointName(name);
    }
    return serverFactoryBean.create();
}
 
Example 7
Source File: CxfTest.java    From java-specialagent with Apache License 2.0 6 votes vote down vote up
@Test
public void testWs(final MockTracer tracer) {
  final String msg = "hello";

  // prepare server
  final JaxWsServerFactoryBean serverFactory = new JaxWsServerFactoryBean();
  serverFactory.setServiceClass(Echo.class);
  serverFactory.setAddress(BASE_URI);
  serverFactory.setServiceBean(new EchoImpl());
  final Server server = serverFactory.create();

  // prepare client
  final JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
  clientFactory.setServiceClass(Echo.class);
  clientFactory.setAddress(BASE_URI);
  final Echo echo = (Echo)clientFactory.create();

  final String response = echo.echo(msg);

  assertEquals(msg, response);
  assertEquals(2, tracer.finishedSpans().size());

  server.destroy();
  serverFactory.getBus().shutdown(true);
}
 
Example 8
Source File: ProviderServiceFactoryTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testStreamSourceProviderCodeFirst() throws Exception {
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(StreamSourcePayloadProvider.class);
    svrFactory.setBus(getBus());
    svrFactory.setServiceBean(new StreamSourcePayloadProvider());
    String address = "http://localhost:9000/test";
    svrFactory.setAddress(address);
    svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID);

    svrFactory.create();

    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);
}
 
Example 9
Source File: TestCXFClientServerInterceptors.java    From kieker with Apache License 2.0 5 votes vote down vote up
private Server startServer() {
	final JaxWsServerFactoryBean srvFactory = new JaxWsServerFactoryBean();
	srvFactory.setServiceClass(IBookstore.class);
	srvFactory.setAddress(TestCXFClientServerInterceptors.SERVICE_ADDRESS);
	srvFactory.setServiceBean(new BookstoreImpl());

	// On the server-side, we only intercept incoming requests and outgoing responses.
	srvFactory.getInInterceptors().add(new OperationExecutionSOAPRequestInInterceptor(this.serverMonitoringController));
	srvFactory.getOutInterceptors().add(new OperationExecutionSOAPResponseOutInterceptor(this.serverMonitoringController));
	return srvFactory.create();
}
 
Example 10
Source File: MultipleServiceShareClassTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void registerService(final Class<?> service, final Object serviceImpl) {
    final JaxWsServerFactoryBean builder = new JaxWsServerFactoryBean();
    builder.setBus(getBus());
    builder.setAddress("http://localhost:" + PORT + "/" + service.getSimpleName());
    builder.setServiceBean(serviceImpl);
    builder.setServiceClass(service);
    builder.create();
}
 
Example 11
Source File: ServerJMS.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static void launchCxfApi() {
    Object implementor = new HelloWorldImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(HelloWorld.class);
    svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
    svrFactory.setAddress(JMS_ENDPOINT_URI);
    svrFactory.setServiceBean(implementor);
    svrFactory.setFeatures(Collections.singletonList(new LoggingFeature()));
    svrFactory.create();
}
 
Example 12
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Server() throws Exception {
    System.out.println("Starting Server");
    HelloWorldImpl implementor = new HelloWorldImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(HelloWorld.class);
    svrFactory.setAddress("http://localhost:9000/helloWorld");
    svrFactory.setServiceBean(implementor);
    svrFactory.getFeatures().add(new LoggingFeature());
    svrFactory.create();
}
 
Example 13
Source File: WebServiceTaskTest.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
	super.initializeProcessEngine();

	counter = new CounterImpl();
	JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
	svrFactory.setServiceClass(Counter.class);
	svrFactory.setAddress("http://localhost:12345/counter");
	svrFactory.setServiceBean(counter);
	svrFactory.getInInterceptors().add(new LoggingInInterceptor());
	svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
	server = svrFactory.create();
	server.start();
}
 
Example 14
Source File: StudentTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testWSDL() throws Exception {
    JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    sf.setServiceClass(StudentService.class);
    sf.setServiceBean(new StudentServiceImpl());
    sf.setAddress("local://StudentService");
    setupAegis(sf);
    Server server = sf.create();
    Document wsdl = getWSDLDocument(server);

    assertValid("//*[@name='string2stringMap']", wsdl);
}
 
Example 15
Source File: AbstractConnectionITHelper.java    From tracee with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected JaxWsServerFactoryBean createJaxWsServer() {
	JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean();
	serverFactoryBean.setServiceClass(HelloWorldTestServiceImpl.class);
	serverFactoryBean.setAddress(endpointAddress);
	serverFactoryBean.setServiceBean(new HelloWorldTestServiceImpl(serverBackend));
	serverFactoryBean.setBus(CXFBusFactory.getDefaultBus());
	return serverFactoryBean;
}
 
Example 16
Source File: UDPTransportTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setAddress("udp://:" + PORT);
    factory.setServiceClass(Greeter.class);
    factory.setServiceBean(new GreeterImpl());
    // factory.setFeatures(Collections.singletonList(new LoggingFeature()));
    server = factory.create();
}
 
Example 17
Source File: TestUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static Server createTeachersResourceFactoryEndpoint(ResourceRemote resource, String port) {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceClass(ResourceFactory.class);
    factory.setServiceBean(resource);
    factory.setAddress("http://localhost:" + port + "/ResourceTeachers" + TransferConstants.RESOURCE_REMOTE_SUFFIX);
    return factory.create();
}
 
Example 18
Source File: HttpTestActivator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Server createTestServer(String url) {
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setServiceClass(Greeter.class);
    factory.setAddress(url);
    factory.setServiceBean(new GreeterImpl());
    return factory.create();
}
 
Example 19
Source File: AbstractWebServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
	super.initializeProcessEngine();

   webServiceMock = new WebServiceMockImpl();
	JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
	svrFactory.setServiceClass(WebServiceMock.class);
   svrFactory.setAddress("http://localhost:63081/webservicemock");
   svrFactory.setServiceBean(webServiceMock);
	svrFactory.getInInterceptors().add(new LoggingInInterceptor());
	svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
	server = svrFactory.create();
	server.start();
}
 
Example 20
Source File: WebServiceTaskTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeProcessEngine() {
    super.initializeProcessEngine();

    webServiceMock = new WebServiceMockImpl();
    JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
    svrFactory.setServiceClass(WebServiceMock.class);
    svrFactory.setAddress("http://localhost:63081/webservicemock");
    svrFactory.setServiceBean(webServiceMock);
    svrFactory.getInInterceptors().add(new LoggingInInterceptor());
    svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    server = svrFactory.create();
    server.start();
}