endpoint.getFeatures().addAll(clientFac.getFeatures());
@Override public void configure(final JaxWsProxyFactoryBean factory) { factory.getFeatures().add(new BraveClientFeature(brave)); } });
@Override public void configure(final JaxWsProxyFactoryBean factory) { factory.getFeatures().add(new BraveClientFeature(brave)); } });
@Override public void configure(final JaxWsProxyFactoryBean factory) { factory.getFeatures().add(new OpenTracingClientFeature(tracer)); } });
@Override public void configure(final JaxWsProxyFactoryBean factory) { factory.getFeatures().add(new OpenTracingClientFeature(tracer)); } });
public <T> T createCallbackProxy(final Class<T> proxyInterface) { final JaxWsProxyFactoryBean callback = new JaxWsProxyFactoryBean(); callback.setServiceName(serviceName); callback.setEndpointName(new QName(serviceName.getNamespaceURI(), serviceName.getLocalPart() + "Port")); callback.setAddress(replyToAddress); callback.setServiceClass(proxyInterface); final List<Feature> features = callback.getFeatures(); features.add(new RequestCallbackFeature()); if (logging) { features.add(new LoggingFeature()); } if (serviceActivityMonitoring) { features.add(getEventFeature()); } final Map<String, Object> properties = new HashMap<String, Object>(); properties.put(RequestCallbackFeature.CALLCONTEXT_PROPERTY_NAME, this); callback.setProperties(properties); return callback.create(proxyInterface); }
/** * Initialize JAXWS proxy factory bean * @param factory JAXWS Proxy factory bean */ public void initializeFactory(JaxWsProxyFactoryBean factory) { // set outgoing security (username/password) if (StringUtils.isNotEmpty(getHttpUser())) { factory.setUsername(getHttpUser()); factory.setPassword(getHttpPassword()); } // enable WS-addressing if (StringUtils.isNotEmpty(getWSAddressingToUri())) { factory.getFeatures().add(new WSAddressingFeature()); } }
@Override public void configure(final JaxWsProxyFactoryBean factory) { factory.getFeatures().add(new OpenTracingClientFeature(tracer)); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.getInInterceptors().add(new LoggingInInterceptor()); } });
@Override public void configure(final JaxWsProxyFactoryBean factory) { factory.getFeatures().add(new BraveClientFeature(brave)); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.getInInterceptors().add(new LoggingInInterceptor()); } });
/** * Creates a charging station web service proxy. * * @param chargingStationAddress address of the charging station. * @return charging station web service proxy */ public ChargePointService createChargingStationService(String chargingStationAddress) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(ChargePointService.class); factory.setAddress(chargingStationAddress); SoapBindingConfiguration conf = new SoapBindingConfiguration(); conf.setVersion(Soap12.getInstance()); factory.setBindingConfig(conf); factory.getFeatures().add(new WSAddressingFeature()); ChargePointService chargePointService = (ChargePointService) factory.create(); //Force the use of the Async transport, even for synchronous calls ((BindingProvider) chargePointService).getRequestContext().put("use.async.http.conduit", Boolean.TRUE); return chargePointService; }
/** * Creates a vas subscriber web service proxy based on the delivery address. * * @param deliveryAddress delivery address * @return subscriber web service proxy */ public VasSubscriberService createVasSubscriberService(String deliveryAddress) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(VasSubscriberService.class); factory.setAddress(deliveryAddress); SoapBindingConfiguration conf = new SoapBindingConfiguration(); conf.setVersion(Soap12.getInstance()); factory.setBindingConfig(conf); factory.getFeatures().add(new WSAddressingFeature()); VasSubscriberService vasSubscriberService = (VasSubscriberService) factory.create(); //Force the use of the Async transport, even for synchronous calls ((BindingProvider) vasSubscriberService).getRequestContext().put("use.async.http.conduit", Boolean.TRUE); return vasSubscriberService; }
/** * Creates a charging station web service proxy. * * @param chargingStationAddress address of the charging station. * @return charging station web service proxy */ public ChargePointService createChargingStationService(String chargingStationAddress) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(ChargePointService.class); factory.setAddress(chargingStationAddress); SoapBindingConfiguration conf = new SoapBindingConfiguration(); conf.setVersion(Soap12.getInstance()); factory.setBindingConfig(conf); factory.getFeatures().add(new WSAddressingFeature()); ChargePointService chargePointService = (ChargePointService) factory.create(); //Force the use of the Async transport, even for synchronous calls ((BindingProvider) chargePointService).getRequestContext().put("use.async.http.conduit", Boolean.TRUE); return chargePointService; }
private Greeter createGreeterProxy() throws Exception { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setBus(bus); factory.getFeatures().add(cff); factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID); factory.setServiceClass(Greeter.class); factory.setAddress(SERVICE_ADDRESS); return (Greeter)markForClose(factory.create()); }
@Test public void testCxfWsaFeature() throws Exception { ByteArrayOutputStream input = setupInLogging(); ByteArrayOutputStream output = setupOutLogging(); JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(AddNumbersPortType.class); factory.setAddress("http://localhost:" + PORT + "/jaxws/add"); factory.getFeatures().add(new WSAddressingFeature()); AddNumbersPortType port = (AddNumbersPortType) factory.create(); ((BindingProvider)port).getRequestContext().put("ws-addressing.write.optional.replyto", Boolean.TRUE); assertEquals(3, port.addNumbers(1, 2)); assertLogContains(output.toString(), "//wsa:Address", "http://www.w3.org/2005/08/addressing/anonymous"); assertLogContains(input.toString(), "//wsa:RelatesTo", getLogValue(output.toString(), "//wsa:MessageID")); }
@Test public void testGzip() throws Exception { URL wsdl = getWSDLURL(WSDL); JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setBus(bus); factory.setServiceClass(JMSGreeterPortType.class); factory.setWsdlURL(wsdl.toExternalForm()); factory.getFeatures().add(cff); factory.getFeatures().add(new GZIPFeature()); factory.setAddress("jms:queue:test.cxf.jmstransport.queue6"); JMSGreeterPortType greeter = (JMSGreeterPortType)markForClose(factory.create()); for (int idx = 0; idx < 5; idx++) { greeter.greetMeOneWay("test String"); String greeting = greeter.greetMe("Milestone-" + idx); Assert.assertEquals("Hello Milestone-" + idx, greeting); String reply = greeter.sayHi(); Assert.assertEquals("Bonjour", reply); } }
private void specNoWsdlService(String messageType) throws Exception { String address = SERVICE_ADDRESS + ((messageType != null) ? "&messageType=" + messageType : ""); JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setBus(bus); factory.getFeatures().add(cff); factory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID); factory.setServiceClass(Hello.class); factory.setAddress(address); Hello client = (Hello)markForClose(factory.create()); String reply = client.sayHi(" HI"); Assert.assertEquals("get HI", reply); }
@Test public void testClientProxyFactory() { JaxWsProxyFactoryBean cf = new JaxWsProxyFactoryBean(); cf.setAddress("http://localhost:" + PORT + "/test"); cf.getFeatures().add(new WSAddressingFeature()); cf.setServiceClass(Greeter.class); Greeter greeter = (Greeter) cf.create(); Client client = ClientProxy.getClient(greeter); checkAddressInterceptors(client.getInInterceptors()); }
@Test public void testUseFailOverOnClient() throws Exception { List<String> serviceList = new ArrayList<>(); serviceList.add("http://localhost:" + PORT + "/SoapContext/GreeterPort"); RandomStrategy strategy = new RandomStrategy(); strategy.setAlternateAddresses(serviceList); FailoverFeature ff = new FailoverFeature(); ff.setStrategy(strategy); // setup the feature by using JAXWS front-end API JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); // set a fake address to kick off the failover feature factory.setAddress("http://localhost:" + PORT2 + "/SoapContext/GreeterPort"); factory.getFeatures().add(ff); factory.setServiceClass(Greeter.class); Greeter proxy = factory.create(Greeter.class); Response<GreetMeResponse> response = proxy.greetMeAsync("cxf"); int waitCount = 0; while (!response.isDone() && waitCount < 15) { Thread.sleep(1000); waitCount++; } assertTrue("Response still not received.", response.isDone()); }
private static <T> T createClient(String port, Class<T> serviceClass, SchemaValidationType type, Feature ... features) { JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean(); clientFactory.setServiceClass(serviceClass); clientFactory.setAddress(getAddress(port, serviceClass)); if (features != null) { clientFactory.getFeatures().addAll(Arrays.asList(features)); } @SuppressWarnings("unchecked") T newClient = (T)clientFactory.create(); Client proxy = ClientProxy.getClient(newClient); if (type != null) { proxy.getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, type); } HTTPConduit conduit = (HTTPConduit) proxy.getConduit(); // give me longer debug times HTTPClientPolicy clientPolicy = new HTTPClientPolicy(); clientPolicy.setConnectionTimeout(1000000); clientPolicy.setReceiveTimeout(1000000); conduit.setClient(clientPolicy); return newClient; }
@Test public void testGet() { // Create the client JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean(); proxyFac.setBus(getStaticBus()); proxyFac.setAddress("http://localhost:" + PORT + "/jaxws/addmex"); proxyFac.getFeatures().add(new LoggingFeature()); MetadataExchange exc = proxyFac.create(MetadataExchange.class); Metadata metadata = exc.get2004(); assertNotNull(metadata); assertEquals(2, metadata.getMetadataSection().size()); assertEquals("http://schemas.xmlsoap.org/wsdl/", metadata.getMetadataSection().get(0).getDialect()); assertEquals("http://apache.org/cxf/systest/ws/addr_feature/", metadata.getMetadataSection().get(0).getIdentifier()); assertEquals("http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(1).getDialect()); GetMetadata body = new GetMetadata(); body.setDialect("http://www.w3.org/2001/XMLSchema"); metadata = exc.getMetadata(body); assertEquals(1, metadata.getMetadataSection().size()); assertEquals("http://www.w3.org/2001/XMLSchema", metadata.getMetadataSection().get(0).getDialect()); } }