Java Code Examples for org.apache.cxf.jaxws.JaxWsServerFactoryBean#create()
The following examples show how to use
org.apache.cxf.jaxws.JaxWsServerFactoryBean#create() .
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: CXFITest.java From java-specialagent with Apache License 2.0 | 6 votes |
public static void main(final String[] args) { final String msg = "hello"; final JaxWsServerFactoryBean serverFactory = new JaxWsServerFactoryBean(); serverFactory.setAddress(BASE_URI); serverFactory.setServiceBean(new EchoImpl()); final Server server = serverFactory.create(); final JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean(); clientFactory.setServiceClass(Echo.class); clientFactory.setAddress(BASE_URI); final Echo echo = (Echo)clientFactory.create(); echo.echo(msg); // CXF Tracing span has no "component" tag, cannot use TestUtil.checkSpan() checkSpans(2); server.destroy(); serverFactory.getBus().shutdown(true); }
Example 2
Source File: WSServerTest.java From cjs_ssms with GNU General Public License v2.0 | 6 votes |
/** * 接口测试 wsdl: http://localhost:9000/wSSample?wsdl * @param args */ public static void main(String[] args) { System.out.println("web service 启动中。。。"); WSSampleImpl implementor = new WSSampleImpl(); String address = "http://192.168.245.221:9000/wSSample"; if (TestEnv.onTTrue) { address = "http://localhost:9000/wSSample"; } JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean(); factoryBean.setAddress(address); // 设置地址 factoryBean.setServiceClass(WSSample.class); // 接口类 factoryBean.setServiceBean(implementor); // 设置实现类 factoryBean.create(); // 创建webservice接口 System.out.println("web service 启动成功。。"); }
Example 3
Source File: HelloWorldImplTest.java From cxf-jaxws with MIT License | 6 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { // start the HelloWorld service using jaxWsServerFactoryBean JaxWsServerFactoryBean jaxWsServerFactoryBean = new JaxWsServerFactoryBean(); // adding loggingFeature to print the received/sent messages LoggingFeature loggingFeature = new LoggingFeature(); loggingFeature.setPrettyLogging(true); jaxWsServerFactoryBean.getFeatures().add(loggingFeature); // setting the implementation HelloWorldImpl implementor = new HelloWorldImpl(); jaxWsServerFactoryBean.setServiceBean(implementor); // setting the endpoint jaxWsServerFactoryBean.setAddress(ENDPOINT_ADDRESS); jaxWsServerFactoryBean.create(); }
Example 4
Source File: JavaFirstSchemaValidationTest.java From cxf with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: MapsTest.java From cxf with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { super.setUp(); JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); sf.setServiceClass(MapTest.class); sf.setServiceBean(new MapTestImpl()); sf.setAddress("local://MapTest"); setupAegis(sf); server = sf.create(); // server.getEndpoint().getInInterceptors().add(new LoggingInInterceptor()); // server.getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor()); server.start(); JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setAddress("local://MapTest"); proxyFac.setServiceClass(MapTest.class); proxyFac.setBus(getBus()); setupAegis(proxyFac.getClientFactoryBean()); clientInterface = (MapTest)proxyFac.create(); }
Example 6
Source File: CxfTest.java From java-specialagent with Apache License 2.0 | 6 votes |
@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 7
Source File: JmsTestActivator.java From cxf with Apache License 2.0 | 5 votes |
private Server publishService(ConnectionFactory connectionFactory) { JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceClass(Greeter.class); factory.setAddress("jms:queue:greeter"); factory.setFeatures(Collections.singletonList(new ConnectionFactoryFeature(connectionFactory))); factory.setServiceBean(new GreeterImpl()); return factory.create(); }
Example 8
Source File: UDPTransportTest.java From cxf with Apache License 2.0 | 5 votes |
@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 9
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@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); }
Example 10
Source File: CatastrophicEventSinkImpl.java From cxf with Apache License 2.0 | 5 votes |
public CatastrophicEventSinkImpl(String url) { JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean(); bean.setServiceBean(this); bean.setAddress(url); this.url = url; server = bean.create(); }
Example 11
Source File: IntegrationBaseTest.java From cxf with Apache License 2.0 | 5 votes |
protected Server createLocalResourceFactory(ResourceManager manager) { ResourceFactoryImpl implementor = new ResourceFactoryImpl(); implementor.setResourceResolver(new SimpleResourceResolver(RESOURCE_ADDRESS, manager)); JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setBus(bus); factory.setServiceClass(ResourceFactory.class); factory.setAddress(RESOURCE_FACTORY_ADDRESS); factory.setServiceBean(implementor); return factory.create(); }
Example 12
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@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); }
Example 13
Source File: AbstractWebServiceTaskTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@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 14
Source File: StaxToDOMSamlTest.java From cxf with Apache License 2.0 | 5 votes |
private Service createService() { // Create the Service JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); return service; }
Example 15
Source File: ProviderServiceFactoryTest.java From cxf with Apache License 2.0 | 5 votes |
@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()); 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); }
Example 16
Source File: SimpleEventingIntegrationTest.java From cxf with Apache License 2.0 | 5 votes |
protected Server createEventSink(String address) { JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setBus(bus); factory.setServiceBean(new TestingEventSinkImpl()); factory.setAddress(address); return factory.create(); }
Example 17
Source File: RoundTripTest.java From steady with Apache License 2.0 | 4 votes |
@Before public void setUpService() throws Exception { JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new SAAJInInterceptor()); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new SAAJOutInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); wsIn = new WSS4JInInterceptor(); wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getInInterceptors().add(wsIn); wsOut = new WSS4JOutInterceptor(); wsOut.setProperty(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.USER, "myalias"); wsOut.setProperty("password", "myAliasPassword"); wsOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getOutInterceptors().add(wsOut); // Create the client JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); echo = (Echo)proxyFac.create(); client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getInInterceptors().add(wsIn); client.getInInterceptors().add(new SAAJInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getOutInterceptors().add(wsOut); client.getOutInterceptors().add(new SAAJOutInterceptor()); }
Example 18
Source File: RoundTripTest.java From steady with Apache License 2.0 | 4 votes |
@Before public void setUpService() throws Exception { JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new SAAJInInterceptor()); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new SAAJOutInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); wsIn = new WSS4JInInterceptor(); wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getInInterceptors().add(wsIn); wsOut = new WSS4JOutInterceptor(); wsOut.setProperty(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.USER, "myalias"); wsOut.setProperty("password", "myAliasPassword"); wsOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getOutInterceptors().add(wsOut); // Create the client JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); echo = (Echo)proxyFac.create(); client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getInInterceptors().add(wsIn); client.getInInterceptors().add(new SAAJInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getOutInterceptors().add(wsOut); client.getOutInterceptors().add(new SAAJOutInterceptor()); }
Example 19
Source File: UserNameTokenAuthorizationTest.java From steady with Apache License 2.0 | 4 votes |
public void setUpService(String expectedRoles, boolean digest, boolean encryptUsernameTokenOnly) throws Exception { JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean(); factory.setServiceBean(new EchoImpl()); factory.setAddress("local://Echo"); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); Server server = factory.create(); Service service = server.getEndpoint().getService(); service.getInInterceptors().add(new SAAJInInterceptor()); service.getInInterceptors().add(new LoggingInInterceptor()); service.getOutInterceptors().add(new SAAJOutInterceptor()); service.getOutInterceptors().add(new LoggingOutInterceptor()); wsIn = new SimpleSubjectCreatingInterceptor(); wsIn.setSupportDigestPasswords(digest); wsIn.setProperty(WSHandlerConstants.SIG_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.DEC_PROP_FILE, "insecurity.properties"); wsIn.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getInInterceptors().add(wsIn); SimpleAuthorizingInterceptor sai = new SimpleAuthorizingInterceptor(); sai.setMethodRolesMap(Collections.singletonMap("echo", expectedRoles)); service.getInInterceptors().add(sai); wsOut = new WSS4JOutInterceptor(); wsOut.setProperty(WSHandlerConstants.SIG_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.ENC_PROP_FILE, "outsecurity.properties"); wsOut.setProperty(WSHandlerConstants.USER, "myalias"); if (digest) { wsOut.setProperty("password", "myAliasPassword"); } else { wsOut.setProperty(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT); } if (encryptUsernameTokenOnly) { wsOut.setProperty(WSHandlerConstants.ENCRYPTION_USER, "myalias"); wsOut.setProperty( WSHandlerConstants.ENCRYPTION_PARTS, "{Content}{" + WSConstants.WSSE_NS + "}UsernameToken" ); } wsOut.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, TestPwdCallback.class.getName()); service.getOutInterceptors().add(wsOut); // Create the client JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setServiceClass(Echo.class); proxyFac.setAddress("local://Echo"); proxyFac.getClientFactoryBean().setTransportId(LocalTransportFactory.TRANSPORT_ID); echo = (Echo)proxyFac.create(); ((BindingProvider)echo).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE); client = ClientProxy.getClient(echo); client.getInInterceptors().add(new LoggingInInterceptor()); client.getInInterceptors().add(wsIn); client.getInInterceptors().add(new SAAJInInterceptor()); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getOutInterceptors().add(wsOut); client.getOutInterceptors().add(new SAAJOutInterceptor()); }
Example 20
Source File: PublishedEndpointUrlTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testPublishedEndpointUrl() throws Exception { Greeter implementor = new org.apache.hello_world_soap_http.GreeterImpl(); String publishedEndpointUrl = "http://cxf.apache.org/publishedEndpointUrl"; Bus bus = BusFactory.getDefaultBus(); JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setBus(bus); svrFactory.setServiceClass(Greeter.class); svrFactory.setAddress("http://localhost:" + PORT + "/publishedEndpointUrl"); svrFactory.setPublishedEndpointUrl(publishedEndpointUrl); svrFactory.setServiceBean(implementor); Server server = svrFactory.create(); WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose", false); URL url = new URL(svrFactory.getAddress() + "?wsdl=1"); HttpURLConnection connect = (HttpURLConnection)url.openConnection(); assertEquals(500, connect.getResponseCode()); Definition wsdl = wsdlReader.readWSDL(svrFactory.getAddress() + "?wsdl"); assertNotNull(wsdl); Collection<Service> services = CastUtils.cast(wsdl.getAllServices().values()); final String failMesg = "WSDL provided incorrect soap:address location"; for (Service service : services) { Collection<Port> ports = CastUtils.cast(service.getPorts().values()); for (Port port : ports) { List<?> extensions = port.getExtensibilityElements(); for (Object extension : extensions) { String actualUrl = null; if (extension instanceof SOAP12Address) { actualUrl = ((SOAP12Address)extension).getLocationURI(); } else if (extension instanceof SOAPAddress) { actualUrl = ((SOAPAddress)extension).getLocationURI(); } //System.out.println("Checking url: " + actualUrl + " against " + publishedEndpointUrl); assertEquals(failMesg, publishedEndpointUrl, actualUrl); } } } server.stop(); server.destroy(); bus.shutdown(true); }