@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) {
final QName qname = new QName(Settings.MAIN_SCAN_SERVICE_SOAP_URL.get().toString(), "PortName"); final String wsdlUrl = Settings.MAIN_SCAN_SERVICE_WSDL_URL.get().toString(); final JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean(); jaxWsProxyFactoryBean.setAddress(Settings.MAIN_SCAN_SERVICE_SOAP_URL.get().toString()); jaxWsProxyFactoryBean.setEndpointName(qname); jaxWsProxyFactoryBean.setServiceName(new QName(wsdlUrl, "PortName")); jaxWsProxyFactoryBean.setWsdlLocation(wsdlUrl); jaxWsProxyFactoryBean.setServiceClass(PortImpl.class); this.portImpl = (PortImpl) jaxWsProxyFactoryBean.create();
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); }
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getClientFactoryBean().getServiceFactory().setWsdlURL(WinRmService.WSDL_LOCATION); factory.setServiceName(WinRmService.SERVICE); factory.setEndpointName(WinRmService.WinRmPort); // factory.setFeatures(...); // if required Service winrm = factory.create(WinRm.class); Client client = ClientProxy.getClient(winrm);
private static WinRm doCreateServiceWithBean(Bus bus) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getClientFactoryBean().getServiceFactory().setWsdlURL(WinRmService.WSDL_LOCATION); factory.setServiceName(WinRmService.SERVICE); factory.setEndpointName(WinRmService.WinRmPort); factory.setBus(bus); return factory.create(WinRm.class); }
clientFactoryBean.setAddress(address); clientFactoryBean.setServiceName(SERVICE_QNAME); clientFactoryBean.setEndpointName(portQName); clientFactoryBean.setServiceClass(DoubleItPortType.class);
factory.setTransportId(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID); factory.setServiceName(new QName("http://cxf.apache.org/swa", "SwAService")); factory.setEndpointName(new QName("http://cxf.apache.org/swa", "SwAServiceJMSPort")); factory.setAddress(ADDRESS + broker.getEncodedBrokerURL()); factory.getOutInterceptors().add(new LoggingOutInterceptor());
@Test(expected = SOAPFaultException.class) public void testReplyAndReplyToDestinations() throws Exception { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setWsdlLocation("classpath:/wsdl/jms_test.wsdl"); factory.setServiceName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService")); factory.setEndpointName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort")); factory.setAddress("jms://"); JMSConfigFeature feature = new JMSConfigFeature(); JMSConfiguration config = new JMSConfiguration(); config.setConnectionFactory(new ActiveMQConnectionFactory(broker.getBrokerURL())); config.setRequestURI("test.jmstransport.text"); config.setTargetDestination("test.jmstransport.text"); // replyDestination and replyToDestination intentionally differ in this test scenario // replyDestination = Destination name to listen on for reply messages config.setReplyDestination("test.jmstransport.text.reply"); // replyToDestination = Destination name to send out as replyTo address in the message config.setReplyToDestination("test.jmstransport.text.replyTo"); config.setReceiveTimeout(1000L); feature.setJmsConfig(config); factory.getFeatures().add(feature); HelloWorldPortType greeter = factory.create(HelloWorldPortType.class); try { greeter.greetMe("FooBar"); // Timeout exception should be thrown } finally { ((java.io.Closeable)greeter).close(); } }
cf.setServiceName(getService()); if (getEndpoint() != null) { cf.setEndpointName(new QName(getService().getNamespaceURI(), getEndpoint()));