public Client createClient(String address, String soapVersion) { return withContextClassLoader(CxfClientFactory.class.getClassLoader(), () -> { ClientFactoryBean factory = new ClientFactoryBean(); factory.setServiceClass(ProxyService.class); factory.setDataBinding(new StaxDataBinding()); factory.getFeatures().add(new StaxDataBindingFeature()); factory.setAddress(address); factory.setBus(bus); factory.setBindingId(getBindingIdForSoapVersion(soapVersion)); return factory.create(); }); }
protected String getConfiguredName() { QName name = getEndpointName(); if (name == null) { JaxWsServiceFactoryBean sfb = (JaxWsServiceFactoryBean)getClientFactoryBean().getServiceFactory(); name = sfb.getJaxWsImplementorInfo().getEndpointName(); } return name + ".jaxws-client.proxyFactory"; }
protected void applyFeatures(Client client) { if (getFeatures() != null) { for (Feature feature : getFeatures()) { feature.initialize(client, getBus()); } } }
public QName getEndpointName() { QName qn = clientFactoryBean.getEndpointName(); if (qn == null) { qn = clientFactoryBean.getServiceFactory().getEndpointName(false); } return qn; }
this.enhancedResponse = enhancedResponse; clientFactory = new ClientFactoryBean(); clientFactory.setServiceClass(GenericServiceClass.class); clientFactory.getServiceFactory().getServiceConfigurations().add(0, new AbstractServiceConfiguration() { @Override public Boolean isOperation(Method method) { clientFactory.setServiceName(serviceName); clientFactory.setEndpointName(portName); if (!useServiceRegistry) { String endpointUrl = (useServiceLocator) ? "locator://" + serviceName.getLocalPart() : publishedEndpointUrl; clientFactory.setAddress(endpointUrl); clientFactory.setWsdlURL(wsdlURL); clientFactory.setDataBinding(new SourceDataBinding()); clientFactory.setBus(bus); features.add(new org.apache.cxf.feature.LoggingFeature()); clientFactory.setFeatures(features); clientFactory.setProperties(clientProps);
protected void setupClientFactoryBean(ClientFactoryBean factoryBean, Class<?> cls) { if (cls != null) { factoryBean.setServiceClass(cls); factoryBean.setInInterceptors(in); factoryBean.setOutInterceptors(out); factoryBean.setOutFaultInterceptors(outFault); factoryBean.setInFaultInterceptors(inFault); factoryBean.setFeatures(features); factoryBean.setTransportId(transportId); factoryBean.setBindingId(bindingId); factoryBean.setBindingConfig(bindingConfig); factoryBean.setDataBinding(dataBinding); factoryBean.setAddress(getAddress()); factoryBean.setWsdlURL(getWsdlURL()); factoryBean.setServiceName(getServiceName()); factoryBean.setEndpointName(getPortName()); feature.addInIntercepters(getInInterceptors()); feature.addOutInterceptors(getOutInterceptors()); factoryBean.getFeatures().add(feature); } else if (getDataFormat().dealias() == DataFormat.CXF_MESSAGE) { factoryBean.getFeatures().add(new CXFMessageDataFormatFeature()); factoryBean.setDataBinding(new SourceDataBinding());
AegisDatabinding dataBinding = ... {your dataBinding}; ClientFactoryBean clientProxyFactoryBean = new ClientFactoryBean(); clientProxyFactoryBean.setDataBinding(dataBinding); // Path to wsdl clientProxyFactoryBean.setAddress("http://servername/app?wsdl"); // implemented service clientProxyFactoryBean.setServiceClass(com.exigen.aaa.rating.home.ca.RatingService.class); Client client = clientProxyFactoryBean.create(); DataReader<XMLStreamReader> dataReader = dataBinding.createReader(XMLStreamReader.class); String tempData = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>..."; XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader streamReader = factory.createXMLStreamReader(new StringReader(tempData)); // miss all soap messages while (true) { if (streamReader.isStartElement()) { System.out.println(streamReader.getName()); if ("{http://your.object.value/}arg1".equals(streamReader.getName().toString())) { break; } } streamReader.next(); } Object result = dataReader.read(streamReader);
clientFactoryBean.setProperties(properties); clientFactoryBean.setBus(bus); clientFactoryBean.setDataBinding(dataBinding); Client c = clientFactoryBean.create(); if (getInInterceptors() != null) { c.getInInterceptors().addAll(getInInterceptors()); Object obj = ProxyHelper.getProxy(getClassLoader(clientFactoryBean.getServiceClass()), classes, handler);
private CreditAgencyWS getProxy() { // Here we use JaxWs front end to create the proxy JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean(); ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean(); clientBean.setAddress(creditAgencyAddress); clientBean.setServiceClass(CreditAgencyWS.class); clientBean.setBus(BusFactory.getDefaultBus()); return (CreditAgencyWS)proxyFactory.create(); }
public Client create() { getServiceFactory().reset(); if (getServiceFactory().getProperties() == null) { getServiceFactory().setProperties(properties); } else if (properties != null) { getServiceFactory().getProperties().putAll(properties); } Client client = null; Endpoint ep = null; try { ep = createEndpoint(); this.getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_CLIENT_CREATE, ep); applyProperties(ep); client = createClient(ep); initializeAnnotationInterceptors(ep, getServiceClass()); } catch (EndpointException | BusException e) { throw new ServiceConstructionException(e); } applyFeatures(client); this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep); return client; }
public void setServiceClass(Class<?> serviceClass) { super.setServiceClass(serviceClass); if (((JaxWsServiceFactoryBean)getServiceFactory()).getJaxWsImplementorInfo() == null) { JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(serviceClass); ((JaxWsServiceFactoryBean)getServiceFactory()).setJaxWsImplementorInfo(implInfo); } }
serviceQName = factoryBean.getServiceName(); } catch (IllegalStateException e) { factoryBean.setServiceName(new QName(getServiceNamespace(), getServiceLocalName())); if (factoryBean.getEndpointName() == null && getEndpointLocalName() != null) { factoryBean.setEndpointName(new QName(getEndpointNamespace(), getEndpointLocalName())); checkName(factoryBean.getEndpointName(), "endpoint/port name"); checkName(factoryBean.getServiceName(), "service name"); Client client = factoryBean.create();
@Override public <T> T getPort(String address, Class<T> serviceInterface, Class<?>... extraClasses) { ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { if (setClassLoader) { Thread.currentThread().setContextClassLoader(WSNHelper.class.getClassLoader()); } JaxWsProxyFactoryBean jwfb = new JaxWsProxyFactoryBean(); jwfb.getClientFactoryBean().setWsdlURL(WSNWSDLLocator.getWSDLUrl().toExternalForm()); jwfb.setServiceName(new QName("http://cxf.apache.org/wsn/jaxws", serviceInterface.getSimpleName() + "Service")); jwfb.setEndpointName(new QName("http://cxf.apache.org/wsn/jaxws", serviceInterface.getSimpleName() + "Port")); jwfb.setAddress(address); if (extraClasses != null && extraClasses.length > 0) { Map<String, Object> props = new HashMap<>(); props.put("jaxb.additionalContextClasses", extraClasses); jwfb.getClientFactoryBean().getServiceFactory().setProperties(props); } return jwfb.create(serviceInterface); } finally { Thread.currentThread().setContextClassLoader(cl); } } public Endpoint publish(String address, Object o, Class<?> ... extraClasses) {
@Override public void setBindingId(String bind) { if (SOAPBinding.SOAP11HTTP_BINDING.equals(bind) || SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(bind)) { super.setBindingId("http://schemas.xmlsoap.org/wsdl/soap/"); } else if (SOAPBinding.SOAP12HTTP_BINDING.equals(bind) || SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(bind)) { super.setBindingId("http://schemas.xmlsoap.org/wsdl/soap12/"); } else { super.setBindingId(bind); } if (SOAPBinding.SOAP11HTTP_BINDING.equals(bind) || SOAPBinding.SOAP12HTTP_BINDING.equals(bind)) { setBindingConfig(new JaxWsSoapBindingConfiguration((JaxWsServiceFactoryBean)getServiceFactory())); } else if (SOAPBinding.SOAP11HTTP_MTOM_BINDING.equals(bind) || SOAPBinding.SOAP12HTTP_MTOM_BINDING.equals(bind)) { setBindingConfig(new JaxWsSoapBindingConfiguration((JaxWsServiceFactoryBean)getServiceFactory())); ((JaxWsSoapBindingConfiguration)getBindingConfig()).setMtomEnabled(true); } }
public void setAddress(String add) { clientFactoryBean.setAddress(add); }
checkName(factoryBean.getEndpointName(), "endpoint/port name"); checkName(factoryBean.getServiceName(), "service name"); Client client = factoryBean.create();
public void setBus(Bus bus) { this.bus = bus; clientFactoryBean.setBus(bus); }
private Client getClient() throws BusException, EndpointException { if (client == null) { client = clientFactory.create(); if (null != authorizationPolicy) { HTTPConduit conduit = (HTTPConduit) client.getConduit(); conduit.setAuthorization(authorizationPolicy); } } return client; }
throw new RemoteApiException("Unable to initialize JAXB context for webservice client", jaxbe); factory.getClientFactoryBean().setDataBinding(jaxbDataBinding);
public ClientProxyFactoryBean() { this(new ClientFactoryBean()); } public ClientProxyFactoryBean(ClientFactoryBean fact) {