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

The following examples show how to use javax.xml.ws.Endpoint#create() . 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: RetransmissionGZIPTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run()  {
    SpringBusFactory bf = new SpringBusFactory();
    Bus bus = bf.createBus("/org/apache/cxf/systest/ws/rm/gzip-enabled.xml");
    BusFactory.setDefaultBus(bus);
    LoggingInInterceptor in = new LoggingInInterceptor();
    bus.getInInterceptors().add(in);
    bus.getInFaultInterceptors().add(in);
    LoggingOutInterceptor out = new LoggingOutInterceptor();
    bus.getOutInterceptors().add(out);
    bus.getOutFaultInterceptors().add(out);

    GreeterImpl implementor = new GreeterImpl();
    String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort";

    Endpoint ep = Endpoint.create(implementor);
    ep.publish(address);

    LOG.info("Published greeter endpoint.");
}
 
Example 2
Source File: EndpointAPITest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultiplePublishSameAddress() throws Exception {
    server.start();
    String contextPath = "/ctxt";
    String path = "/echo";
    //need to use the same HttpContext, otherwise Grizzly get confused
    HttpContext ctx = GrizzlyHttpContextFactory.createHttpContext(server, contextPath, path);
    for (int i = 0; i < 3; i++) {
        String address = "http://localhost:" + currentPort + contextPath + path;

        Endpoint endpoint = Endpoint.create(new EndpointBean());
        endpoint.publish(ctx); // Use grizzly HTTP context for publishing

        invokeEndpoint(address);

        endpoint.stop();
    }
}
 
Example 3
Source File: Publish.java    From juddi with Apache License 2.0 6 votes vote down vote up
public static void main (String args[]) {
	
	System.out.println("1. Bring up the hello world endpoint at port 18080");
	Endpoint helloWorldEndPoint = Endpoint.create(new HelloWorldImpl());
	helloWorldEndPoint.publish("http://localhost:18080/services/helloworld");
	
	System.out.println("2. Programmatically publish the endpoint to UDDI");
	Publish sp = new Publish();
	try {
		uddiClient = new UDDIClient("META-INF/wsdl2uddi-uddi.xml");
		UDDIClerk clerk = uddiClient.getClerk("joe");
		
		System.out.println("setting up the publisher");
		sp.setupJoePublisher(clerk);
		System.out.println("publish the business");
		sp.publishBusiness(clerk);
		System.out.println("and the wsdl");
		sp.publishWSDL(clerk);
		
		System.out.println("waiting for calls into the HelloWorldImpl...");
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 4
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 5
Source File: CachedOutMessageTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run()  {
    SpringBusFactory bf = new SpringBusFactory();
    Bus bus = bf.createBus("/org/apache/cxf/systest/ws/rm/message-loss.xml");
    BusFactory.setDefaultBus(bus);
    setBus(bus);
    LoggingInInterceptor in = new LoggingInInterceptor();
    bus.getInInterceptors().add(in);
    bus.getInFaultInterceptors().add(in);
    LoggingOutInterceptor out = new LoggingOutInterceptor();
    bus.getOutInterceptors().add(out);
    bus.getOutFaultInterceptors().add(out);

    GreeterImpl implementor = new GreeterImpl();
    String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort";

    ep = Endpoint.create(implementor);
    ep.publish(address);

    LOG.info("Published greeter endpoint.");
}
 
Example 6
Source File: EndpointAPITest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultipleEndpointsDifferentContexts() throws Exception {
    server.start();
    String contextPath = "/ctxt";
    String path = "/echo";
    int k = 3;
    Endpoint[] endpoints = new Endpoint[k];
    HttpContext[] contexts = new HttpContext[k];
    String[] addresses = new String[k];
    for (int i = 0; i < k; i++) {
        addresses[i] = "http://localhost:" + currentPort + contextPath + i + path;
        contexts[i] = GrizzlyHttpContextFactory.createHttpContext(server,
                                                                  contextPath + i,
                                                                  path);
        endpoints[i] = Endpoint.create(new EndpointBean());
        endpoints[i].publish(contexts[i]);
    }
    for (int i = 0; i < k; i++) {
        invokeEndpoint(addresses[i]);
    }
    for (int i = 0; i < k; i++) {
        endpoints[i].stop();
    }
}
 
Example 7
Source File: Server.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run()  {
    System.setProperty("org.apache.cxf.bus.factory", "org.apache.cxf.bus.CXFBusFactory");
    Object implementor = new PutLastTradedPriceImpl();
    String address = "http://localhost:" + PORT + "/SOAPDocLitBareService/SoapPort";
    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(address);
    implementor = new BareSoapServiceImpl();
    address = "http://localhost:" + PORT + "/SOAPDocLitBareService/SoapPort1";
    ep = Endpoint.create(implementor);
    ep.publish(address);
}
 
Example 8
Source File: EndpointAPITest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultipleEndpointsSameContext() throws Exception {
    server.start();
    String contextPath = "/ctxt";
    String path = "/echo";
    int k = 3;
    Endpoint[] endpoints = new Endpoint[k];
    HttpContext[] contexts = new HttpContext[k];
    String[] addresses = new String[k];
    for (int i = 0; i < k; i++) {
        addresses[i] = "http://localhost:" + currentPort + contextPath + path + i;
        contexts[i] = GrizzlyHttpContextFactory.createHttpContext(server,
                                                                  contextPath,
                                                                  path + i);
        endpoints[i] = Endpoint.create(new EndpointBean());
        endpoints[i].publish(contexts[i]);
    }
    for (int i = 0; i < k; i++) {
        invokeEndpoint(addresses[i]);
    }
    for (int i = 0; i < k; i++) {
        endpoints[i].stop();
    }
}
 
Example 9
Source File: AbstractJaxWsServiceExporter.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create the actual Endpoint instance.
 * @param bean the service object to wrap
 * @return the Endpoint instance
 * @see Endpoint#create(Object)
 * @see Endpoint#create(String, Object)
 */
@UsesJava7  // optional use of Endpoint#create with WebServiceFeature[]
protected Endpoint createEndpoint(Object bean) {
	if (this.endpointFeatures != null || this.webServiceFeatures != null) {
		WebServiceFeature[] endpointFeaturesToUse = this.endpointFeatures;
		if (endpointFeaturesToUse == null) {
			endpointFeaturesToUse = new WebServiceFeature[this.webServiceFeatures.length];
			for (int i = 0; i < this.webServiceFeatures.length; i++) {
				endpointFeaturesToUse[i] = convertWebServiceFeature(this.webServiceFeatures[i]);
			}
		}
		return Endpoint.create(this.bindingType, bean, endpointFeaturesToUse);
	}
	else {
		return Endpoint.create(this.bindingType, bean);
	}
}
 
Example 10
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {

        TestProvider implementor = new TestProvider();
        Endpoint ep = Endpoint.create(implementor);
        ((EndpointImpl)ep).setWsdlLocation("wsdl_systest/mtom_provider_validate.wsdl");
        ep.publish("http://localhost:" + PORT + "/mtom/provider");
    }
 
Example 11
Source File: JaxwsEndpointManager.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Endpoint createEndpoint(Object service) {
    String bindingId = SOAPBinding.SOAP11HTTP_BINDING;
    if (isCXF()) {
        bindingId = SOAPBinding.SOAP12HTTP_BINDING;
    }
    return Endpoint.create(bindingId, service);
}
 
Example 12
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    String address;
    Object implementor = new RPCLitGreeterImpl();
    address = "http://localhost:" + PORT + "/SOAPServiceRPCLit/SoapPort";
    ep = Endpoint.create(implementor);

    URL wsdl = getClass().getResource(wsdlLocation);
    ((EndpointImpl)ep).setWsdlLocation(wsdl.toString());
    ((EndpointImpl)ep).getInInterceptors().add(new LoggingInInterceptor());
    ((EndpointImpl)ep).getOutInterceptors().add(new LoggingOutInterceptor());
    ep.publish(address);
}
 
Example 13
Source File: SoapJmsSpecTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void startServers() throws Exception {
    startBusAndJMS(SoapJmsSpecTest.class);

    publish("jms:queue:test.cxf.jmstransport.queue2", new GreeterSpecImpl());
    publish("jms:queue:test.cxf.jmstransport.queue5", new GreeterSpecWithPortError());

    EndpointImpl ep = (EndpointImpl)Endpoint.create(null, new GreeterSpecImpl());
    ep.setBus(bus);
    ep.getFeatures().add(new GZIPFeature());
    ep.getFeatures().add(cff);
    ep.publish("jms:queue:test.cxf.jmstransport.queue6");
}
 
Example 14
Source File: Test.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String deployWebservice() throws IOException {
    // Manually create HttpServer here using ephemeral address for port
    // so as to not end up with attempt to bind to an in-use port
    httpServer = HttpServer.create(new InetSocketAddress(0), 0);
    httpServer.start();
    endpoint = Endpoint.create(new ServiceImpl());
    endpoint.publish(httpServer.createContext("/wservice"));

    String wsdlAddress = "http://localhost:" + httpServer.getAddress().getPort() + "/wservice?wsdl";
    log("address = " + wsdlAddress);
    return wsdlAddress;
}
 
Example 15
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 16
Source File: Test.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String deployWebservice() throws IOException {
    // Manually create HttpServer here using ephemeral address for port
    // so as to not end up with attempt to bind to an in-use port
    httpServer = HttpServer.create(new InetSocketAddress(0), 0);
    httpServer.start();
    endpoint = Endpoint.create(new ServiceImpl());
    endpoint.publish(httpServer.createContext("/wservice"));

    String wsdlAddress = "http://localhost:" + httpServer.getAddress().getPort() + "/wservice?wsdl";
    log("address = " + wsdlAddress);
    return wsdlAddress;
}
 
Example 17
Source File: ProviderJMSContinuationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void startServers() throws Exception {
    startBusAndJMS(ProviderJMSContinuationTest.class);
    Object implementor = new HWSoapMessageDocProvider();
    String address = "jms:queue:test.jmstransport.text?replyToQueueName=test.jmstransport.text.reply";
    EndpointImpl ep = (EndpointImpl)Endpoint.create(implementor);
    ep.getInInterceptors().add(new IncomingMessageCounterInterceptor());
    ep.setBus(bus);
    ep.getFeatures().add(cff);
    ep.publish(address);
}
 
Example 18
Source File: Test.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String deployWebservice() throws IOException {
    // Manually create HttpServer here using ephemeral address for port
    // so as to not end up with attempt to bind to an in-use port
    httpServer = HttpServer.create(new InetSocketAddress(0), 0);
    httpServer.start();
    endpoint = Endpoint.create(new ServiceImpl());
    endpoint.publish(httpServer.createContext("/wservice"));

    String wsdlAddress = "http://localhost:" + httpServer.getAddress().getPort() + "/wservice?wsdl";
    log("address = " + wsdlAddress);
    return wsdlAddress;
}
 
Example 19
Source File: Server.java    From cxf with Apache License 2.0 2 votes vote down vote up
/**
 * If you prefer to define the ConnectionFactory directly instead of using a JNDI look.
// You can inject is like this:
 * @param impl
 * @param cf
 */
protected void publishEndpoint(Object impl, ConnectionFactory cf) {
    EndpointImpl epi = (EndpointImpl)Endpoint.create(impl);
    epi.setFeatures(Collections.singletonList(new ConnectionFactoryFeature(cf)));
    epi.publish();
}
 
Example 20
Source File: AbstractJaxWsServiceExporter.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Create the actual Endpoint instance.
 * @param bean the service object to wrap
 * @return the Endpoint instance
 * @see Endpoint#create(Object)
 * @see Endpoint#create(String, Object)
 */
protected Endpoint createEndpoint(Object bean) {
	return (this.endpointFeatures != null ?
			Endpoint.create(this.bindingType, bean, this.endpointFeatures) :
			Endpoint.create(this.bindingType, bean));
}