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

The following examples show how to use javax.xml.ws.Endpoint#setMetadata() . 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: 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);
    }
}