public Future<?> invokeAsync(T obj, AsyncHandler<T> asyncHandler) { checkError(); client.setExecutor(getClient().getEndpoint().getExecutor());
public void addVersionTransformer(Dispatch<Object> dispatch) { Map<String, String> nsMap = new HashMap<>(); nsMap.put("tns", NS_1_1); nsMap.put("wsa", getAddressingNamespace()); ((DispatchImpl)dispatch).getClient().getEndpoint().getEndpointInfo() .setProperty("soap.env.ns.map", nsMap); } public QName getServiceName() {
public void addVersionTransformer(Dispatch<Object> dispatch) { Map<String, String> nsMap = new HashMap<>(); nsMap.put("tns", NS_1_1); nsMap.put("wsa", getAddressingNamespace()); ((DispatchImpl)dispatch).getClient().getEndpoint().getEndpointInfo() .setProperty("soap.env.ns.map", nsMap); } public QName getServiceName() {
public void addVersionTransformer(Dispatch<Object> dispatch) { StaxTransformFeature feature = new StaxTransformFeature(); Map<String, String> outElements = new HashMap<>(); outElements.put("{" + NS_1_1 + "}*", "{" + NS_1_0 + "}*"); outElements.put("{" + INSTANCE_1_1.getAddressingNamespace() + "}*", "{" + getAddressingNamespace() + "}*"); feature.setOutTransformElements(outElements); Map<String, String> inElements = new HashMap<>(); inElements.put("{" + NS_1_0 + "}*", "{" + NS_1_1 + "}*"); inElements.put("{" + getAddressingNamespace() + "}*", "{" + INSTANCE_1_1.getAddressingNamespace() + "}*"); feature.setInTransformElements(inElements); feature.initialize(((DispatchImpl)dispatch).getClient(), ((DispatchImpl)dispatch).getClient().getBus()); Map<String, String> nsMap = new HashMap<>(); nsMap.put("tns", NS_1_0); nsMap.put("wsa", getAddressingNamespace()); ((DispatchImpl)dispatch).getClient().getEndpoint().getEndpointInfo() .setProperty("soap.env.ns.map", nsMap); } public QName getServiceName() {
public void addVersionTransformer(Dispatch<Object> dispatch) { StaxTransformFeature feature = new StaxTransformFeature(); Map<String, String> outElements = new HashMap<>(); outElements.put("{" + NS_1_1 + "}*", "{" + NS_1_0 + "}*"); outElements.put("{" + INSTANCE_1_1.getAddressingNamespace() + "}*", "{" + getAddressingNamespace() + "}*"); feature.setOutTransformElements(outElements); Map<String, String> inElements = new HashMap<>(); inElements.put("{" + NS_1_0 + "}*", "{" + NS_1_1 + "}*"); inElements.put("{" + getAddressingNamespace() + "}*", "{" + INSTANCE_1_1.getAddressingNamespace() + "}*"); feature.setInTransformElements(inElements); feature.initialize(((DispatchImpl)dispatch).getClient(), ((DispatchImpl)dispatch).getClient().getBus()); Map<String, String> nsMap = new HashMap<>(); nsMap.put("tns", NS_1_0); nsMap.put("wsa", getAddressingNamespace()); ((DispatchImpl)dispatch).getClient().getEndpoint().getEndpointInfo() .setProperty("soap.env.ns.map", nsMap); } public QName getServiceName() {
public <T> Dispatch<T> configureDispatch(Dispatch<T> dispatch) { if (!(dispatch instanceof DispatchImpl<?>) || (serviceName == null && configuration == null)) { return null; } final DispatchImpl<?> di = (DispatchImpl<?>) dispatch; final Client cl = di.getClient(); try { String jmsAddr = getJmsAddress(); cl.getRequestContext().put(Message.ENDPOINT_ADDRESS, jmsAddr); cl.getEndpoint().getEndpointInfo().setAddress(jmsAddr); } catch (Exception e) { if (LOGGER.isLoggable(Level.FINER)) { LOGGER.log(Level.FINER, "Exception caught: ", e); } return null; } return dispatch; }
public <T> Dispatch<T> configureDispatch(Dispatch<T> dispatch) { if (jmsConfiguration == null || !(dispatch instanceof DispatchImpl<?>) || (serviceName == null && configuration == null)) { return null; } if (!jmsConfigured) { setupJmsConfiguration(); } final DispatchImpl<?> di = (DispatchImpl<?>) dispatch; final Client cl = di.getClient(); final JMSConfigFeature feature = new JMSConfigFeature(); feature.setJmsConfig(jmsConfiguration); feature.initialize(cl, cl.getBus()); return dispatch; }
public static void setupDispatch(final Dispatch<?> dispatch) { if (!(dispatch instanceof DispatchImpl)) { throw new IllegalArgumentException("Only CXF JAX-WS Dispatch supported. "); } final DispatchImpl<?> dsp = (DispatchImpl<?>) dispatch; final Client dispatchClient = dsp.getClient(); final Bus bus = dispatchClient.getBus(); (new RequestCallbackFeature()).initialize(dispatchClient, bus); if (logging) { (new LoggingFeature()).initialize(dispatchClient, bus); } if (serviceActivityMonitoring) { getEventFeature().initialize(dispatchClient, bus); } }
public <T> Dispatch<T> configureDispatch(Dispatch<T> dispatch, String addressing) { if (configuration == null) { if (serviceName == null) { return null; } configuration = CallContext.resolveConfiguration(serviceName); } String overrideAddress = getProperty("requestURI2010"); if (overrideAddress != null && (overrideAddress.equals(addressing) || OVERRIDE_BY_URI_CONFIG.equals(addressing))) { return dispatch; } if (jmsConfiguration == null || !(dispatch instanceof DispatchImpl<?>) || (serviceName == null && configuration == null)) { return null; } if (!jmsConfigured) { setupJmsConfiguration(); } final DispatchImpl<?> di = (DispatchImpl<?>) dispatch; final Client cl = di.getClient(); final JMSConfigFeature feature = new JMSConfigFeature(); feature.setJmsConfig(jmsConfiguration); feature.initialize(cl, cl.getBus()); return dispatch; }
Client cl = dsp.getClient(); final QName serviceName; try {
protected void setConfigProperties(Object client, ClientConfig config) { Client cxfClient; if (client instanceof DispatchImpl<?>) { cxfClient = ((DispatchImpl<?>)client).getClient(); } else { cxfClient = ClientProxy.getClient(client); } cleanupPreviousProps(cxfClient); Map<String, String> props = config.getProperties(); if (props != null && !props.isEmpty()) { savePropList(cxfClient, props); } setConfigProperties(cxfClient, props); //config jaspi JASPIAuthenticationProvider japsiProvider = (JASPIAuthenticationProvider) ServiceLoader.loadService( JASPIAuthenticationProvider.class.getName(), null, ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader()); if (japsiProvider != null) { japsiProvider.enableClientAuthentication(cxfClient, props); } else { Loggers.SECURITY_LOGGER.cannotFindJaspiClasses(); } }
protected void setupClient(Object obj, Class<?> seiClass, WebServiceFeature... features) { Binding binding = ((BindingProvider)obj).getBinding(); Client client = obj instanceof DispatchImpl<?> ? ((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj); ClientConfig config = readConfig(seiClass); if (config != null) { CXFClientConfigurer helper = new CXFClientConfigurer(); helper.setupConfigHandlers(binding, config); helper.setConfigProperties(client, config.getProperties()); } client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding)); //add this *after* the config has been set (if any)! if (features != null) { for (WebServiceFeature f : features) { if (f instanceof AbstractClientFeature) { ((AbstractClientFeature)f).initialize(obj); } } } }
props.put(ConfigurationConstants.SIG_PROP_FILE, "alice.properties"); WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(props); Client client = ((DispatchImpl<StreamSource>) dispatch).getClient(); client.getOutInterceptors().add(outInterceptor);
props.put(ConfigurationConstants.SIG_PROP_FILE, "alice.properties"); WSS4JOutInterceptor outInterceptor = new WSS4JOutInterceptor(props); Client client = ((DispatchImpl<StreamSource>) dispatch).getClient(); client.getOutInterceptors().add(outInterceptor);
Client client = ((DispatchImpl<DOMSource>) dispatch).getClient(); client.getRequestContext().put( SecurityConstants.CALLBACK_HANDLER,
@org.junit.Test public void testTrailingWhitespaceInSOAPBody() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = SignatureWhitespaceTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = SignatureWhitespaceTest.class.getResource("DoubleItAction.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItSignaturePort2"); Dispatch<StreamSource> dispatch = service.createDispatch(portQName, StreamSource.class, Service.Mode.MESSAGE); Client client = ((DispatchImpl<StreamSource>) dispatch).getClient(); HTTPConduit http = (HTTPConduit) client.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(0); httpClientPolicy.setReceiveTimeout(0); http.setClient(httpClientPolicy); // Creating a DOMSource Object for the request URL requestFile = SignatureWhitespaceTest.class.getResource("request-with-trailing-whitespace.xml"); StreamSource request = new StreamSource(new File(requestFile.getPath())); updateAddressPort(dispatch, test.getPort()); // Make a successful request StreamSource response = dispatch.invoke(request); assertNotNull(response); Document doc = StaxUtils.read(response.getInputStream()); assertEquals("50", doc.getElementsByTagNameNS(null, "doubledNumber").item(0).getTextContent()); ((java.io.Closeable)dispatch).close(); }
@Test public void testEchoProviderAsyncDecoupledEndpoints() throws Exception { String requestString = "<echo/>"; Service service = Service.create(serviceName); service.addPort(fakePortName, javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider"); Dispatch<StreamSource> dispatcher = service.createDispatch(fakePortName, StreamSource.class, Service.Mode.PAYLOAD, new LoggingFeature()); Client client = ((DispatchImpl<StreamSource>)dispatcher).getClient(); WSAddressingFeature wsAddressingFeature = new WSAddressingFeature(); wsAddressingFeature.initialize(client, client.getBus()); dispatcher.getRequestContext().put("org.apache.cxf.ws.addressing.replyto", "http://localhost:" + CLIENT_PORT + "/SoapContext/AsyncEchoClient"); StreamSource request = new StreamSource(new ByteArrayInputStream(requestString.getBytes())); StreamSource response = dispatcher.invoke(request); assertEquals(requestString, StaxUtils.toString(response)); } }
public Future<?> invokeAsync(T obj, AsyncHandler<T> asyncHandler) { checkError(); client.setExecutor(getClient().getEndpoint().getExecutor());
HTTPConduit cond = (HTTPConduit)dispImpl.getClient().getConduit(); cond.getClient().setConnectionTimeout(500);
private static Dispatch<Source> createUsernameTokenDispatcher(boolean decoupled, String port) { final Service service = Service.create( GREETER_SERVICE_QNAME ); service.addPort( USERNAME_TOKEN_PORT_QNAME, decoupled ? SOAPBinding.SOAP11HTTP_BINDING : HTTPBinding.HTTP_BINDING, "http://localhost:" + port + "/GreeterService/UsernameTokenPort" ); final Dispatch<Source> dispatcher = service.createDispatch( USERNAME_TOKEN_PORT_QNAME, Source.class, Service.Mode.MESSAGE, new AddressingFeature(decoupled, decoupled) ); final java.util.Map<String, Object> requestContext = dispatcher.getRequestContext(); requestContext.put( MessageContext.HTTP_REQUEST_METHOD, "POST" ); if (decoupled) { HTTPConduit cond = (HTTPConduit)((DispatchImpl<?>)dispatcher).getClient().getConduit(); cond.getClient().setDecoupledEndpoint("http://localhost:" + DEC_PORT + "/decoupled"); } return dispatcher; }