Java Code Examples for javax.xml.ws.Endpoint#setProperties()

The following examples show how to use javax.xml.ws.Endpoint#setProperties() . 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: WSNHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
public Endpoint publish(String address, Object o, Class<?> ... extraClasses) {
    if (extraClasses != null && extraClasses.length > 0) {
        throw new UnsupportedOperationException("Pure JAX-WS does not support the extraClasses");
    }
    Endpoint endpoint = Endpoint.create(o);
    URL wsdlLocation = WSNWSDLLocator.getWSDLUrl();
    if (wsdlLocation != null) {
        try {
            if (endpoint.getProperties() == null) {
                endpoint.setProperties(new HashMap<String, Object>());
            }
            endpoint.getProperties().put("javax.xml.ws.wsdl.description", wsdlLocation.toExternalForm());
            List<Source> mt = new ArrayList<>();
            StreamSource src = new StreamSource(wsdlLocation.openStream(), wsdlLocation.toExternalForm());
            mt.add(src);
            endpoint.setMetadata(mt);
        } catch (IOException e) {
            //ignore, no wsdl really needed
        }
    }

    endpoint.publish(address);
    return endpoint;
}
 
Example 2
Source File: CXFWSNHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
public Endpoint publish(String address, Object o, Class<?> ... extraClasses) {
    Endpoint endpoint = Endpoint.create(SOAPBinding.SOAP12HTTP_BINDING, o);
    if (extraClasses != null && extraClasses.length > 0) {
        Map<String, Object> props = new HashMap<>();
        props.put("jaxb.additionalContextClasses", extraClasses);
        endpoint.setProperties(props);
    }
    URL wsdlLocation = WSNWSDLLocator.getWSDLUrl();
    if (wsdlLocation != null) {
        try {
            if (endpoint.getProperties() == null) {
                endpoint.setProperties(new HashMap<String, Object>());
            }
            endpoint.getProperties().put("javax.xml.ws.wsdl.description", wsdlLocation.toExternalForm());
            List<Source> mt = new ArrayList<>();
            StreamSource src = new StreamSource(wsdlLocation.openStream(), wsdlLocation.toExternalForm());
            mt.add(src);
            endpoint.setMetadata(mt);
        } catch (IOException e) {
            //ignore, no wsdl really needed
        }
    }
    endpoint.publish(address);
    return endpoint;
}
 
Example 3
Source File: AbstractJaxWsServiceExporter.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Assert.state(this.beanFactory != null, "No BeanFactory set");

	Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
	Collections.addAll(beanNames, this.beanFactory.getBeanDefinitionNames());
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		Collections.addAll(beanNames, ((ConfigurableBeanFactory) this.beanFactory).getSingletonNames());
	}

	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
Example 4
Source File: AbstractJaxWsServiceExporter.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Assert.state(this.beanFactory != null, "No BeanFactory set");

	Set<String> beanNames = new LinkedHashSet<>(this.beanFactory.getBeanDefinitionCount());
	Collections.addAll(beanNames, this.beanFactory.getBeanDefinitionNames());
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		Collections.addAll(beanNames, ((ConfigurableBeanFactory) this.beanFactory).getSingletonNames());
	}

	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
Example 5
Source File: AbstractJaxWsServiceExporter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Set<String> beanNames = new LinkedHashSet<String>(this.beanFactory.getBeanDefinitionCount());
	beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
	}
	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
Example 6
Source File: AbstractJaxWsServiceExporter.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Publish all {@link javax.jws.WebService} annotated beans in the
 * containing BeanFactory.
 * @see #publishEndpoint
 */
public void publishEndpoints() {
	Set<String> beanNames = new LinkedHashSet<String>(this.beanFactory.getBeanDefinitionCount());
	beanNames.addAll(Arrays.asList(this.beanFactory.getBeanDefinitionNames()));
	if (this.beanFactory instanceof ConfigurableBeanFactory) {
		beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
	}
	for (String beanName : beanNames) {
		try {
			Class<?> type = this.beanFactory.getType(beanName);
			if (type != null && !type.isInterface()) {
				WebService wsAnnotation = type.getAnnotation(WebService.class);
				WebServiceProvider wsProviderAnnotation = type.getAnnotation(WebServiceProvider.class);
				if (wsAnnotation != null || wsProviderAnnotation != null) {
					Endpoint endpoint = createEndpoint(this.beanFactory.getBean(beanName));
					if (this.endpointProperties != null) {
						endpoint.setProperties(this.endpointProperties);
					}
					if (this.executor != null) {
						endpoint.setExecutor(this.executor);
					}
					if (wsAnnotation != null) {
						publishEndpoint(endpoint, wsAnnotation);
					}
					else {
						publishEndpoint(endpoint, wsProviderAnnotation);
					}
					this.publishedEndpoints.add(endpoint);
				}
			}
		}
		catch (CannotLoadBeanClassException ex) {
			// ignore beans where the class is not resolvable
		}
	}
}
 
Example 7
Source File: SchemaValidationClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    String address;
    Object implementor = new ServicePortTypeImpl();
    address = "http://localhost:" + PORT + "/schemavalidation";
    Endpoint ep = Endpoint.create(implementor);
    Map<String, Object> map = new HashMap<>();
    map.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
    ep.setProperties(map);
    ((EndpointImpl)ep).setWsdlLocation("wsdl_systest_jaxws/schemaValidation.wsdl");
    ((EndpointImpl)ep).setServiceName(new QName(
                           "http://cxf.apache.org/jaxws/schemavalidation", "service"));
    ((EndpointImpl)ep).getInInterceptors().add(new LoggingInInterceptor());
    ((EndpointImpl)ep).getOutInterceptors().add(new LoggingOutInterceptor());
    ep.publish(address);
}
 
Example 8
Source File: ServerGreeterNoWsdl.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    Object implementor = new GreeterImplNoWsdl();
    String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort";
    Endpoint ep = Endpoint.create(implementor);
    Map<String, Object> props = new HashMap<>();
    props.put(WSDLGetUtils.WSDL_CREATE_IMPORTS, Boolean.TRUE);
    ep.setProperties(props);
    ep.publish(address);
}
 
Example 9
Source File: XMLServer.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    Object implementor = new HWDOMSourcePayloadXMLBindingProvider();
    Endpoint ep = Endpoint.create(implementor);
    Map<String, Object> map = new HashMap<>();
    map.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
    ep.setProperties(map);
    ep.publish(ADDRESS);
}
 
Example 10
Source File: ProviderClientServerTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    Object implementor = new HWSoapMessageDocProvider();
    Endpoint ep = Endpoint.create(implementor);
    Map<String, Object> map = new HashMap<>();
    map.put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
    ep.setProperties(map);
    ((EndpointImpl)ep).getInInterceptors().add(new LoggingInInterceptor());
    ((EndpointImpl)ep).getOutInterceptors().add(new LoggingOutInterceptor());
    ep.publish(ADDRESS);

}
 
Example 11
Source File: Server.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected void run()  {
        System.setProperty("org.apache.cxf.bus.factory", "org.apache.cxf.bus.CXFBusFactory");
        System.setProperty("cxf.config.file", "org/apache/cxf/systest/outofband/header/cxf.xml");

//        // Create bus
//        SpringBusFactory bf = new SpringBusFactory();
//        bus = bf.createBus(OOBHeaderTest.CONFIG_FILE);
//        BusFactory.setDefaultBus(bus);
//        OOBHeaderTest.registerOutOfBandHeaders(bus);

        // Register expected Headers (namespace, element and class type mapping)

        Object implementor = new OOBHdrServiceImpl();
        Endpoint ep = Endpoint.create(implementor);
        Map<String, Object> props = new HashMap<>(2);
        props.put(Endpoint.WSDL_SERVICE, new QName("http://apache.org/hello_world_doc_lit_bare",
                                                   "SOAPService"));
        props.put(Endpoint.WSDL_PORT, new QName("http://apache.org/hello_world_doc_lit_bare", "SoapPort"));
        ep.setProperties(props);
        ep.publish("http://localhost:" + PORT + "/SOAPDocLitBareService/SoapPort");

        ep = Endpoint.create(implementor);
        props = new HashMap<>(2);
        props.put(Endpoint.WSDL_SERVICE, new QName("http://apache.org/hello_world_doc_lit_bare",
                                                   "SOAPService"));
        props.put(Endpoint.WSDL_PORT, new QName("http://apache.org/hello_world_doc_lit_bare", "SoapPort"));
        props.put("endpoint-processes-headers", "");
        ep.setProperties(props);
        ep.publish("http://localhost:" + PORT + "/SOAPDocLitBareService/SoapPortNoHeader");

        ep = Endpoint.create(implementor);
        props = new HashMap<>(2);
        props.put(Endpoint.WSDL_SERVICE, new QName("http://apache.org/hello_world_doc_lit_bare",
                                                   "SOAPService"));
        props.put(Endpoint.WSDL_PORT, new QName("http://apache.org/hello_world_doc_lit_bare", "SoapPort"));
        props.put("endpoint-processes-headers", "{http://cxf.apache.org/outofband/Header}outofbandHeader");
        ep.setProperties(props);
        ep.publish("http://localhost:" + PORT + "/SOAPDocLitBareService/SoapPortHeader");

        ep = Endpoint.create(new OOBHdrPropertyServiceImpl());
        props = new HashMap<>(2);
        props.put(Endpoint.WSDL_SERVICE, new QName("http://apache.org/hello_world_doc_lit_bare",
                                                   "SOAPService"));
        props.put(Endpoint.WSDL_PORT, new QName("http://apache.org/hello_world_doc_lit_bare", "SoapPort"));
        ep.setProperties(props);
        ep.publish("http://localhost:" + PORT + "/SOAPDocLitBareService/SoapPortHeaderProperty");

    }
 
Example 12
Source File: Server.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected void run() {
    Object implementor = new HWSourcePayloadProvider();
    String address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8";
    Endpoint ep = Endpoint.create(implementor);
    ep.publish(address);

    Map<String, Object> map = new HashMap<>();
    map.put(SourceDataBinding.PREFERRED_FORMAT, "dom");
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-dom";
    ep = Endpoint.create(implementor);
    ep.setProperties(map);
    ep.publish(address);

    map.put(SourceDataBinding.PREFERRED_FORMAT, "sax");
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-sax";
    ep = Endpoint.create(implementor);
    ep.setProperties(map);
    ep.publish(address);

    map.put(SourceDataBinding.PREFERRED_FORMAT, "stax");
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stax";
    ep = Endpoint.create(implementor);
    ep.setProperties(map);
    ep.publish(address);

    map.put(SourceDataBinding.PREFERRED_FORMAT, "cxf.stax");
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-cxfstax";
    ep = Endpoint.create(implementor);
    ep.setProperties(map);
    ep.publish(address);

    map.put(SourceDataBinding.PREFERRED_FORMAT, "stream");
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit8-stream";
    ep = Endpoint.create(implementor);
    ep.setProperties(map);
    ep.publish(address);


    implementor = new HWSoapMessageProvider();
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1";
    Endpoint.publish(address, implementor);

    implementor = new HWDOMSourceMessageProvider();
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit2";
    Endpoint.publish(address, implementor);

    implementor = new HWDOMSourcePayloadProvider();
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit3";
    Endpoint.publish(address, implementor);

    implementor = new HWSAXSourceMessageProvider();
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit4";
    Endpoint.publish(address, implementor);

    implementor = new HWStreamSourceMessageProvider();
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit5";
    Endpoint.publish(address, implementor);

    implementor = new HWSAXSourcePayloadProvider();
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit6";
    Endpoint.publish(address, implementor);

    implementor = new HWStreamSourcePayloadProvider();
    address = "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit7";
    Endpoint.publish(address, implementor);

}
 
Example 13
Source File: JaxwsEndpointManager.java    From cxf with Apache License 2.0 4 votes vote down vote up
public Endpoint register(String address, Object service, URL wsdlLocation)
    throws EndpointRegistrationException {

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    try {
        if (WSNHelper.getInstance().setClassLoader()) {
            Thread.currentThread().setContextClassLoader(JaxwsEndpointManager.class.getClassLoader());
        }
        Endpoint endpoint = createEndpoint(service);
        if (wsdlLocation != null) {
            try {
                if (endpoint.getProperties() == null) {
                    endpoint.setProperties(new HashMap<String, Object>());
                }
                endpoint.getProperties().put("javax.xml.ws.wsdl.description", wsdlLocation.toExternalForm());
                List<Source> mt = new ArrayList<>();
                StreamSource src = new StreamSource(wsdlLocation.openStream(), wsdlLocation.toExternalForm());
                mt.add(src);
                endpoint.setMetadata(mt);
            } catch (IOException e) {
                //ignore, no wsdl really needed
            }
        }
        endpoint.publish(address);

        try {
            if (mbeanServer != null
                && service instanceof AbstractEndpoint) {
                ObjectName on = ((AbstractEndpoint)service).getMBeanName();
                if (on != null) {
                    mbeanServer.registerMBean(service, on);
                }
            }
        } catch (Exception ex) {
            //ignore for now
        }
        return endpoint;
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}