use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class JavaFirstSchemaValidationTest method createServer.
public static Server createServer(String port, Class<?> serviceInterface, Object serviceImpl, SchemaValidationType type, Feature... features) throws IOException {
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setServiceClass(serviceImpl.getClass());
if (features != null) {
Collections.addAll(svrFactory.getFeatures(), features);
}
if (type != null) {
Map<String, Object> properties = new HashMap<>();
properties.put(Message.SCHEMA_VALIDATION_ENABLED, type);
svrFactory.setProperties(properties);
}
svrFactory.setAddress(getAddress(port, serviceInterface));
svrFactory.setServiceBean(serviceImpl);
Server server = svrFactory.create();
serverList.add(server);
return server;
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class TestUtils method createResourceFactory.
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();
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class TestUtils method createStudentsResource.
private static Server createStudentsResource(ResourceManager resourceManager, String port) {
ResourceLocal resourceLocal = new ResourceLocal();
resourceLocal.setManager(resourceManager);
resourceLocal.getResourceTypeIdentifiers().add(new XSDResourceTypeIdentifier(new StreamSource(TestUtils.class.getResourceAsStream("/schema/studentPut.xsd")), new XSLTResourceTransformer(new StreamSource(TestUtils.class.getResourceAsStream("/xslt/studentPut.xsl")), new StudentPutResourceValidator())));
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(Resource.class);
factory.setServiceBean(resourceLocal);
factory.setAddress("http://localhost:" + port + "/ResourceStudents");
return factory.create();
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class ProviderServiceFactoryTest method testSourceMessageProviderCodeFirst.
@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);
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class ProviderServiceFactoryTest method testSOAPBindingFromCode.
@Test
public void testSOAPBindingFromCode() throws Exception {
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
bean.setServiceClass(SOAPSourcePayloadProvider.class);
bean.setBus(getBus());
bean.setInvoker(new JAXWSMethodInvoker(new SOAPSourcePayloadProvider()));
Service service = bean.create();
assertEquals("SOAPSourcePayloadProviderService", 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();
// See if our endpoint was created correctly
assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size());
Endpoint endpoint = server.getEndpoint();
Binding binding = endpoint.getBinding();
assertTrue(binding instanceof SoapBinding);
SoapBindingInfo sb = (SoapBindingInfo) endpoint.getEndpointInfo().getBinding();
assertEquals("document", sb.getStyle());
assertFalse(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);
}
Aggregations