Java Code Examples for org.apache.cxf.jaxws.EndpointImpl#publish()

The following examples show how to use org.apache.cxf.jaxws.EndpointImpl#publish() . 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: Server.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run() {
    Object implementor;
    String address;

    implementor = new GreeterImpl();
    address = "ws://localhost:" + PORT + "/SoapContext/SoapPort";
    Endpoint ep = Endpoint.publish(address, implementor);
    eps.add(ep);

    //publish port with soap12 binding
    address = "ws://localhost:" + PORT + "/SoapContext/SoapPort";
    EndpointImpl e = (EndpointImpl) Endpoint.create(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING,
                                                    new Greeter12Impl());
    e.publish(address);
    eps.add(e);
}
 
Example 2
Source File: ClientMtomXopWithJMSTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void startServers() throws Exception {
    Object implementor = new TestMtomJMSImpl();
    bus = BusFactory.getDefaultBus();

    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
    PooledConnectionFactory cfp = new PooledConnectionFactory(cf);
    cff = new ConnectionFactoryFeature(cfp);

    EndpointImpl ep = (EndpointImpl)Endpoint.create(implementor);
    ep.getFeatures().add(cff);
    ep.getInInterceptors().add(new TestMultipartMessageInterceptor());
    ep.getOutInterceptors().add(new TestAttachmentOutInterceptor());
    //ep.getInInterceptors().add(new LoggingInInterceptor());
    //ep.getOutInterceptors().add(new LoggingOutInterceptor());
    SOAPBinding jaxWsSoapBinding = (SOAPBinding)ep.getBinding();
    jaxWsSoapBinding.setMTOMEnabled(true);
    ep.publish();
}
 
Example 3
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    // We use a null binding id in the call to EndpointImpl
    // constructor. Why?
    final String nullBindingID = null;

    // We need to specify to use defaults on constructing the
    // bus, because our configuration file doesn't have
    // everything needed.
    final boolean useDefaults = true;

    // We configure a new bus for this server.
    setBus(new SpringBusFactory().createBus(configFileURL, useDefaults));

    // This impl class must have the appropriate annotations
    // to match the WSDL file that we are using.
    Object implementor = new GreeterImpl(name);

    // I don't know why this works.
    ep =
        new EndpointImpl(
                getBus(),
                implementor,
                nullBindingID,
                this.getClass().getResource("greeting.wsdl").toString());
    // How the hell do I know what the name of the
    // http-destination is from using this call?
    ep.setEndpointName(new QName("http://apache.org/hello_world", name));
    ep.publish(address);
}
 
Example 4
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    // We use a null binding id in the call to EndpointImpl
    // constructor. Why?
    final String nullBindingID = null;

    // We need to specify to use defaults on constructing the
    // bus, because our configuration file doesn't have
    // everything needed.
    final boolean useDefaults = true;

    // We configure a new bus for this server.
    setBus(new SpringBusFactory().createBus(configFileURL, useDefaults));

    // This impl class must have the appropriate annotations
    // to match the WSDL file that we are using.
    Object implementor = new GreeterImpl(name);

    // I don't know why this works.
    ep =
        new EndpointImpl(
                getBus(),
                implementor,
                nullBindingID,
                this.getClass().getResource("greeting.wsdl").toString());
    // How the hell do I know what the name of the
    // http-destination is from using this call?
    ep.setEndpointName(new QName("http://apache.org/hello_world", name));
    ep.publish(address);
}
 
Example 5
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    Object implementor = new AddNumberImpl();
    String address = "http://localhost:" + PORT + "/jaxws/add";

    EndpointImpl ep = new EndpointImpl(BusFactory.getThreadDefaultBus(),
                                       implementor,
                                       null,
                                       getWsdl());

    ep.publish(address);
    eps.add(ep);

    eps.add(Endpoint.publish(address + "-provider", new AddNumberProvider()));
    eps.add(Endpoint.publish(address + "-providernows", new AddNumberProviderNoWsdl()));
}
 
Example 6
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    Object implementor = new HelloImpl();
    String address = "http://localhost:" + PORT + "/wsa/responses";
    ep = new EndpointImpl(BusFactory.getThreadDefaultBus(),
                          implementor,
                          null,
                          getWsdl());
    ep.publish(address);
}
 
Example 7
Source File: WebServiceListener.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public void open() throws ListenerException {
	if (StringUtils.isNotEmpty(getAddress())) {
		Bus cxfBus = BusFactory.getDefaultBus(false);
		if(cxfBus == null) {
			throw new ListenerException("unable to find SpringBus");
		}
		log.debug("registering listener ["+getName()+"] with JAX-WS CXF Dispatcher on SpringBus ["+cxfBus.getId()+"]");
		endpoint = new EndpointImpl(cxfBus, new MessageProvider(this, getMultipartXmlSessionKey()));
		endpoint.publish("/"+getAddress());
		SOAPBinding binding = (SOAPBinding)endpoint.getBinding();
		binding.setMTOMEnabled(isMtomEnabled());

		if(endpoint.isPublished()) {
			log.debug("published listener ["+getName()+"] on CXF endpoint ["+getAddress()+"]");
		} else {
			log.error("unable to publish listener ["+getName()+"] on CXF endpoint ["+getAddress()+"]");
		}
	}

	//Can bind on multiple endpoints
	if (StringUtils.isNotEmpty(getServiceNamespaceURI())) {
		log.debug("registering listener ["+getName()+"] with ServiceDispatcher by serviceNamespaceURI ["+getServiceNamespaceURI()+"]");
		ServiceDispatcher.getInstance().registerServiceClient(getServiceNamespaceURI(), this);
	}
	else {
		log.debug("registering listener ["+getName()+"] with ServiceDispatcher");
		ServiceDispatcher.getInstance().registerServiceClient(getName(), this); //Backwards compatibility
	}

	super.open();
}
 
Example 8
Source File: WSDiscoveryServiceImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public synchronized boolean startup(boolean optional) {
    String preferIPv4StackValue = System.getProperty("java.net.preferIPv4Stack");
    String preferIPv6AddressesValue = System.getProperty("java.net.preferIPv6Addresses");
    if (!started && client.isAdHoc()) {
        Bus b = BusFactory.getAndSetThreadDefaultBus(bus);
        try {
            udpEndpoint = new EndpointImpl(bus, new WSDiscoveryProvider());
            Map<String, Object> props = new HashMap<>();
            props.put("jaxws.provider.interpretNullAsOneway", "true");
            udpEndpoint.setProperties(props);
            if ("true".equals(preferIPv6AddressesValue) && "false".equals(preferIPv4StackValue)) {
                try {
                    udpEndpoint.publish("soap.udp://[FF02::C]:3702");
                    started = true;
                } catch (Exception e) {
                    LOG.log(Level.WARNING, "Could not start WS-Discovery Service with ipv6 address", e);
                }
            }
            if (!started) {
                udpEndpoint.publish("soap.udp://239.255.255.250:3702");
                started = true;
            }
        } catch (RuntimeException ex) {
            if (!optional) {
                throw ex;
            }
            LOG.log(Level.WARNING, "Could not start WS-Discovery Service.", ex);
        } finally {
            if (b != bus) {
                BusFactory.setThreadDefaultBus(b);
            }
        }
    }
    return true;
}
 
Example 9
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 10
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 11
Source File: HttpNumberFactoryImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void initDefaultServant() {
    servant = new HttpNumberImpl();

    String wsdlLocation = "wsdl/factory_pattern.wsdl";
    String bindingId = null;
    EndpointImpl ep =
        new EndpointImpl(bus, servant, bindingId, wsdlLocation);
    ep.setEndpointName(new QName(NUMBER_SERVICE_QNAME.getNamespaceURI(), "NumberPort"));
    ep.publish(getServantAddressRoot());
    endpoints.add(ep);
    templateEpr = ep.getServer().getDestination().getAddress();
}
 
Example 12
Source File: ManualNumberFactoryImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void initDefaultServant() {
    servant = new ManualNumberImpl();

    String wsdlLocation = "wsdl/factory_pattern.wsdl";
    String bindingId = null;
    EndpointImpl ep =
        new EndpointImpl(bus, servant, bindingId, wsdlLocation);
    ep.setEndpointName(new QName(NUMBER_SERVICE_QNAME.getNamespaceURI(), "NumberPort"));
    ep.publish(getServantAddressRoot());
    endpoints.add(ep);
    templateEpr = ep.getServer().getDestination().getAddress();
}
 
Example 13
Source File: WebServiceConfig.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Bean
public Endpoint coordinator() {
    EndpointImpl endpoint = new EndpointImpl(bus, new CoordinatorPortTypeImpl());
    endpoint.publish("/ws-t11-coordinator/CoordinatorService");
    return endpoint;

}
 
Example 14
Source File: Application.java    From spring-cxf with Apache License 2.0 5 votes vote down vote up
@Bean
// <jaxws:endpoint id="helloWorld" implementor="demo.spring.service.HelloWorldImpl" address="/HelloWorld"/>
public EndpointImpl helloService() {
    Bus bus = (Bus) applicationContext.getBean(Bus.DEFAULT_BUS_ID);
    Object implementor = new HelloWorldImpl();
    EndpointImpl endpoint = new EndpointImpl(bus, implementor);
    endpoint.publish("/hello");
    endpoint.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
    endpoint.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
    return endpoint;
}
 
Example 15
Source File: SecurityPolicyTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testCXF4122() throws Exception {
    Bus epBus = BusFactory.newInstance().createBus();
    BusFactory.setDefaultBus(epBus);
    URL wsdl = SecurityPolicyTest.class.getResource("DoubleIt.wsdl");
    EndpointImpl ep = (EndpointImpl)Endpoint.create(new DoubleItImpl());
    ep.setEndpointName(
        new QName("http://www.example.org/contract/DoubleIt", "DoubleItPortCXF4122")
    );
    ep.setWsdlLocation(wsdl.getPath());
    ep.setAddress(POLICY_CXF4122_ADDRESS);
    ep.publish();
    EndpointInfo ei = ep.getServer().getEndpoint().getEndpointInfo();
    setCryptoProperties(ei, "bob.properties", "revocation.properties");
    ei.setProperty(SecurityConstants.ENABLE_REVOCATION, Boolean.TRUE);

    SpringBusFactory bf = new SpringBusFactory();

    Bus bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    Service service = Service.create(wsdl, SERVICE_QNAME);

    QName portQName = new QName(NAMESPACE, "DoubleItPortCXF4122");
    DoubleItPortType pt = service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(pt, PORT);
    ((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
                                                  new KeystorePasswordCallback());
    ((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,
                                                  "revocation.properties");
    ((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
                                                  "bob.properties");
    // DOM
    try {
        pt.doubleIt(5);
        fail("should fail on server side when do signature validation due the revoked certificates");
    } catch (Exception ex) {
        // expected
    }

    // TODO See WSS-464
    /*
    SecurityTestUtil.enableStreaming(pt);
    try {
        pt.doubleIt(5);
        fail("should fail on server side when do signature validation due the revoked certificates");
    } catch (Exception ex) {
        String errorMessage = ex.getMessage();
        // Different errors using different JDKs...
        System.out.println("ERR1: " + errorMessage);
    }
    */
    ((java.io.Closeable)pt).close();
    ep.stop();
    epBus.shutdown(true);
    bus.shutdown(true);
}
 
Example 16
Source File: WebServiceConfig.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Bean
public Endpoint registration() {
    EndpointImpl endpoint = new EndpointImpl(bus, new RegistrationPortTypeImpl());
    endpoint.publish("/ws-c11/RegistrationService");
    return endpoint;
}
 
Example 17
Source File: WebServiceConfig.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Bean
public Endpoint participant() {
    EndpointImpl endpoint = new EndpointImpl(bus, new ParticipantPortTypeImpl());
    endpoint.publish("/ws-t11-participant/ParticipantService");
    return endpoint;
}
 
Example 18
Source File: WebServiceConfig.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Bean
public Endpoint participant() {
    EndpointImpl endpoint = new EndpointImpl(bus, new ParticipantPortTypeImpl());
    endpoint.publish("/ws-t11-participant/ParticipantService");
    return endpoint;
}
 
Example 19
Source File: AbstractDOMProvider.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void publish() throws Exception {
    String addr = epAddress;
    String wsdlLoc = null;
    String svcNm = null;
    String portNm = null;
    String tgtNmspc = null;
    String binding = null;
    Object obj = webSvcProviderVar.get("wsdlLocation", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_WSDL_LOCATION);
    }
    if (obj instanceof String) {
        wsdlLoc = (String)obj;
    }
    obj = webSvcProviderVar.get("serviceName", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_SERVICE_NAME);
    }
    if (obj instanceof String) {
        svcNm = (String)obj;
    }
    obj = webSvcProviderVar.get("portName", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_PORT_NAME);
    }
    if (obj instanceof String) {
        portNm = (String)obj;
    }
    obj = webSvcProviderVar.get("targetNamespace", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_TGT_NAMESPACE);
    }
    if (obj instanceof String) {
        tgtNmspc = (String)obj;
    }
    if (addr == null) {
        obj = webSvcProviderVar.get("EndpointAddress", scriptScope);
        if (obj != Scriptable.NOT_FOUND && obj instanceof String) {
            addr = (String)obj;
            isBaseAddr = false;
        }
    }
    if (addr == null) {
        throw new JSDOMProviderException(NO_EP_ADDR);
    }
    if (isBaseAddr) {
        if (addr.endsWith("/")) {
            addr += portNm;
        } else {
            addr = addr + "/" + portNm;
        }
    }
    obj = webSvcProviderVar.get("BindingType", scriptScope);
    if (obj != Scriptable.NOT_FOUND && obj instanceof String) {
        binding = (String)obj;
    }
    obj = webSvcProviderVar.get("invoke", webSvcProviderVar);
    if (obj == Scriptable.NOT_FOUND) {
        throw new JSDOMProviderException(NO_INVOKE);
    }
    if (obj instanceof Function) {
        invokeFunc = (Function)obj;
    } else {
        throw new JSDOMProviderException(ILLEGAL_INVOKE_TYPE);
    }

    Bus bus = BusFactory.getThreadDefaultBus();
    JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
    factory.setWsdlLocation(wsdlLoc);
    factory.setBindingId(binding);
    factory.setServiceName(new QName(tgtNmspc, svcNm));
    factory.setEndpointName(new QName(tgtNmspc, portNm));
    ep = new EndpointImpl(bus, this, factory);
    ep.publish(addr);
}
 
Example 20
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();
}