Java Code Examples for org.apache.cxf.jaxws.EndpointImpl

The following examples show how to use org.apache.cxf.jaxws.EndpointImpl. These examples are extracted from open source projects. 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 Project: cxf   Source File: Server.java    License: Apache License 2.0 6 votes vote down vote up
protected Server() throws Exception {
    System.out.println("Starting Server");

    Object implementor = new GreeterImpl();
    String address = "http://localhost:9000/SoapContext/GreeterPort";
    EndpointImpl impl = (EndpointImpl)Endpoint.publish(address, implementor);

    Map<String, Object> outProps = new HashMap<>();
    outProps.put("action", "UsernameToken Timestamp");

    outProps.put("passwordType", "PasswordText");
    outProps.put("user", "Alice");
    outProps.put("passwordCallbackClass", "demo.wssec.server.UTPasswordCallback");

    impl.getOutInterceptors().add(new WSS4JOutInterceptor(outProps));

    Map<String, Object> inProps = new HashMap<>();
    inProps.put("action", "UsernameToken Timestamp");
    inProps.put("passwordType", "PasswordDigest");
    inProps.put("passwordCallbackClass", "demo.wssec.server.UTPasswordCallback");

    impl.getInInterceptors().add(new WSS4JInInterceptor(inProps));
}
 
Example 2
Source Project: cxf   Source File: StaxServer.java    License: Apache License 2.0 6 votes vote down vote up
protected StaxServer() throws Exception {
    System.out.println("Starting StaxServer");

    Object implementor = new GreeterImpl();
    String address = "http://localhost:9000/SoapContext/GreeterPort";
    EndpointImpl impl = (EndpointImpl)Endpoint.publish(address, implementor);

    WSSSecurityProperties properties = new WSSSecurityProperties();
    properties.addAction(WSSConstants.USERNAMETOKEN);
    properties.addAction(WSSConstants.TIMESTAMP);

    properties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_TEXT);
    properties.setTokenUser("Alice");

    properties.setCallbackHandler(new UTPasswordCallback());

    impl.getOutInterceptors().add(new WSS4JStaxOutInterceptor(properties));

    WSSSecurityProperties inProperties = new WSSSecurityProperties();
    inProperties.addAction(WSSConstants.USERNAMETOKEN);
    inProperties.addAction(WSSConstants.TIMESTAMP);
    inProperties.setUsernameTokenPasswordType(WSSConstants.UsernameTokenPasswordType.PASSWORD_DIGEST);
    inProperties.setCallbackHandler(new UTPasswordCallback());

    impl.getInInterceptors().add(new WSS4JStaxInInterceptor(inProperties));
}
 
Example 3
Source Project: cxf   Source File: Server.java    License: Apache License 2.0 6 votes vote down vote up
protected void run() {
    setBus(BusFactory.getDefaultBus());
    getBus().getInInterceptors().add(new LoggingInInterceptor());
    String address = "http://localhost:" + PORT + "/SoapContext/SoapPort";

    Object implementor1 = new GreeterImplMixedStyle(" version1");
    EndpointImpl ep1 = (EndpointImpl) Endpoint.publish(address, implementor1);

    ep1.getServer().getEndpoint().put("version", "1");
    ep1.getServer().getEndpoint().put("allow-multiplex-endpoint", Boolean.TRUE);

    //Register a MediatorInInterceptor on this dummy service

    Object implementor2 = new GreeterImplMixedStyle(" version2");
    EndpointImpl ep2 = (EndpointImpl) Endpoint.publish(address, implementor2);
    ep2.getServer().getEndpoint().put("version", "2");

    MultipleEndpointObserver meo = (MultipleEndpointObserver)
        ep1.getServer().getDestination().getMessageObserver();
    meo.getRoutingInterceptors().clear();
    meo.getRoutingInterceptors().add(new MediatorInInterceptor());
}
 
Example 4
Source Project: cxf   Source File: ClientMtomXopWithJMSTest.java    License: 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 5
Source Project: cxf   Source File: ClientMtomXopTest.java    License: Apache License 2.0 6 votes vote down vote up
protected void run() {
    Object implementor = new TestMtomImpl();
    String address = "http://localhost:" + PORT + "/mime-test";
    String addressProvider = "http://localhost:" + PORT + "/mime-test-provider";
    try {
        jaxep = (EndpointImpl) javax.xml.ws.Endpoint.publish(address, implementor);
        Endpoint ep = jaxep.getServer().getEndpoint();
        ep.getInInterceptors().add(new TestMultipartMessageInterceptor());
        ep.getOutInterceptors().add(new TestAttachmentOutInterceptor());
        jaxep.getInInterceptors().add(new LoggingInInterceptor());
        jaxep.getOutInterceptors().add(new LoggingOutInterceptor());
        SOAPBinding jaxWsSoapBinding = (SOAPBinding) jaxep.getBinding();
        jaxep.getProperties().put("schema-validation-enabled", "true");
        jaxWsSoapBinding.setMTOMEnabled(true);
        EndpointImpl endpoint =
            (EndpointImpl)javax.xml.ws.Endpoint.publish(addressProvider, new TestMtomProviderImpl());
        endpoint.getProperties().put("schema-validation-enabled", "true");
        endpoint.getInInterceptors().add(new LoggingInInterceptor());
        endpoint.getOutInterceptors().add(new LoggingOutInterceptor());

    } catch (Exception e) {
        Thread.currentThread().interrupt();
    }
}
 
Example 6
Source Project: cxf   Source File: Server.java    License: 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 7
Source Project: cxf   Source File: ClientServiceConfigTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void before() throws Exception {
    super.setUp();

    ReflectionServiceFactoryBean factory = new ReflectionServiceFactoryBean();
    factory.setInvoker(new BeanInvoker(new EchoImpl()));
    factory.setDataBinding(new AegisDatabinding());

    ServerFactoryBean svrFac = new ServerFactoryBean();
    svrFac.setAddress("local://Echo");
    svrFac.setServiceFactory(factory);
    svrFac.setServiceClass(Echo.class);
    svrFac.setBus(getBus());
    svrFac.create();

    Endpoint endpoint = Endpoint.create(new EchoImpl());
    impl = (EndpointImpl) endpoint;
    impl.setDataBinding(new AegisDatabinding());
    endpoint.publish("local://JaxWsEcho");
}
 
Example 8
Source Project: cxf   Source File: EndpointDefinitionParser.java    License: Apache License 2.0 6 votes vote down vote up
public static final void setBlocking(ApplicationContext ctx, EndpointImpl impl) {
    AutowireCapableBeanFactory fact = ctx.getAutowireCapableBeanFactory();
    if (fact instanceof DefaultListableBeanFactory) {
        DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory)fact;
        for (BeanPostProcessor bpp : dlbf.getBeanPostProcessors()) {
            if (CommonAnnotationBeanPostProcessor.class.isInstance(bpp)) {
                impl.getServerFactory().setBlockPostConstruct(true);
                impl.getServerFactory().setBlockInjection(false);
                return;
            }
            if (bpp instanceof Jsr250BeanPostProcessor) {
                impl.getServerFactory().setBlockInjection(true);
            }
        }
    }
}
 
Example 9
Source Project: cxf   Source File: ProviderImpl.java    License: Apache License 2.0 6 votes vote down vote up
public Endpoint createEndpoint(String bindingId, Class<?> implementorClass,
                               Invoker invoker, WebServiceFeature ... features) {
    if (EndpointUtils.isValidImplementor(implementorClass)) {
        Bus bus = BusFactory.getThreadDefaultBus();
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        if (features != null) {
            factory.getJaxWsServiceFactory().setWsFeatures(Arrays.asList(features));
        }
        if (invoker != null) {
            factory.setInvoker(new JAXWSMethodInvoker(invoker));
            try {
                invoker.inject(new WebServiceContextImpl());
            } catch (Exception e) {
                throw new WebServiceException(new Message("ENDPOINT_CREATION_FAILED_MSG",
                                                          LOG).toString(), e);
            }
        }
        EndpointImpl ep = new EndpointImpl(bus, null, factory);
        ep.setImplementorClass(implementorClass);
        return ep;
    }
    throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString());
}
 
Example 10
Source Project: cxf   Source File: ProviderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testInvocation() throws Exception {
    try (EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider(), (String) null)) {
        ep.publish("local://localhost:9000/Provider");

        Node response = invoke("local://localhost:9000/Provider",
                               LocalTransportFactory.TRANSPORT_ID,
                               "/org/apache/cxf/jaxws/sayHi.xml");

        assertNotNull(response);
        assertNoFault(response);

        addNamespace("j", "http://service.jaxws.cxf.apache.org/");
        assertValid("//s:Body/j:sayHi", response);
    }
}
 
Example 11
Source Project: cxf   Source File: ProviderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCXF1852() throws Exception {
    try (EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider2(), (String) null)) {
        ep.publish("local://localhost:9001/Provider2");

        Node response = invoke("local://localhost:9001/Provider2",
                               LocalTransportFactory.TRANSPORT_ID,
                               "/org/apache/cxf/jaxws/sayHi.xml");

        assertNotNull(response);
        assertNoFault(response);

        addNamespace("j", "http://service.jaxws.cxf.apache.org/");
        assertValid("//s:Body/j:sayHi", response);
    }
}
 
Example 12
Source Project: iaf   Source File: NamespaceUriProviderBean.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	//TODO look into NamespaceHandlerResolver
	Bus bus = (Bus) applicationContext.getBean("cxf");
	if(bus instanceof SpringBus) {
		log.debug("default CXF SpringBus ["+bus.getId()+"]");

		log.info("registering NamespaceURI Provider with JAX-WS CXF Dispatcher");
		namespaceRouter = new EndpointImpl(bus, new NamespaceUriProvider());
		namespaceRouter.publish("/rpcrouter");

		if(namespaceRouter.isPublished()) {
			log.info("published NamespaceURI Provider on CXF endpoint [rpcrouter] on SpringBus ["+namespaceRouter.getBus().getId()+"]");
		} else {
			throw new IllegalStateException("unable to NamespaceURI Service Provider on CXF endpoint [rpcrouter]");
		}
	} else {
		throw new IllegalStateException("CXF bus ["+bus+"] not instance of [SpringBus]");
	}
}
 
Example 13
Source Project: iaf   Source File: IbisApplicationInitializer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected WebApplicationContext createWebApplicationContext(ServletContext servletContext) {
	System.setProperty(EndpointImpl.CHECK_PUBLISH_ENDPOINT_PERMISSON_PROPERTY_WITH_SECURITY_MANAGER, "false");
	servletContext.log("Starting IBIS WebApplicationInitializer");

	XmlWebApplicationContext applicationContext = new XmlWebApplicationContext();
	applicationContext.setConfigLocation(XmlWebApplicationContext.CLASSPATH_URL_PREFIX + "/webApplicationContext.xml");
	applicationContext.setDisplayName("IbisApplicationInitializer");

	MutablePropertySources propertySources = applicationContext.getEnvironment().getPropertySources();
	propertySources.remove(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
	propertySources.remove(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME);
	propertySources.addFirst(new PropertiesPropertySource("ibis", AppConstants.getInstance()));

	return applicationContext;
}
 
Example 14
@Bean
public Endpoint sonosEndpoint(Bus bus, SonosService sonosService,
        SonosFaultInterceptor sonosFaultInterceptor,
        SonosLinkSecurityInterceptor sonosSecurity) {
    EndpointImpl endpoint = new EndpointImpl(bus, sonosService);
    endpoint.setOutFaultInterceptors(Collections.singletonList(sonosFaultInterceptor));
    endpoint.setInInterceptors(Collections.singletonList(sonosSecurity));
    endpoint.publish("/Sonos");
    return endpoint;
}
 
Example 15
Source Project: airsonic   Source File: SonosConfiguration.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Bean
public Endpoint sonosEndpoint(SonosService sonosService, SonosFaultInterceptor sonosFaultInterceptor) {
    EndpointImpl endpoint = new EndpointImpl(sonosService);
    endpoint.publish("/Sonos");
    endpoint.setOutFaultInterceptors(Collections.singletonList(sonosFaultInterceptor));
    return endpoint;
}
 
Example 16
Source Project: spring-cxf   Source File: Application.java    License: 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 17
Source Project: cxf   Source File: MDBActivationWork.java    License: Apache License 2.0 5 votes vote down vote up
private Server createServerFromJaxwsEndpoint(JaxWsServerFactoryBean factory) {

        @SuppressWarnings("resource")
        EndpointImpl endpoint = new EndpointImpl(factory.getBus(), null, factory);

        endpoint.setWsdlLocation(factory.getWsdlURL());
        endpoint.setImplementorClass(factory.getServiceClass());
        endpoint.setEndpointName(factory.getEndpointName());
        endpoint.setServiceName(factory.getServiceName());
        endpoint.setInvoker(factory.getInvoker());
        endpoint.setSchemaLocations(factory.getSchemaLocations());

        return endpoint.getServer(factory.getAddress());
    }
 
Example 18
Source Project: cxf   Source File: WebServiceConfig.java    License: 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 19
Source Project: cxf   Source File: Server.java    License: Apache License 2.0 5 votes vote down vote up
protected Server() throws Exception {
    System.out.println("Starting Server");

    Object implementor = new GreeterImpl();
    String address = "http://localhost:9000/SoapContext/SoapPort";
    EndpointImpl ep = (EndpointImpl)Endpoint.publish(address, implementor, new LoggingFeature());

    ep.getOutInterceptors().add(new StreamInterceptor());
}
 
Example 20
Source Project: cxf   Source File: Server.java    License: 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 21
Source Project: cxf   Source File: ManualNumberFactoryImpl.java    License: 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 22
Source Project: cxf   Source File: HttpNumberFactoryImpl.java    License: 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 23
Source Project: cxf   Source File: Server.java    License: 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 24
Source Project: cxf   Source File: MissingQualification1226Test.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void lookForMissingNamespace() throws Exception {
    EndpointImpl endpoint = getBean(EndpointImpl.class, "helloWorld");
    Document d = getWSDLDocument(endpoint.getServer());
    NodeList schemas = assertValid("//xsd:schema[@targetNamespace='http://nstest.helloworld']", d);
    Element schemaElement = (Element)schemas.item(0);
    String ef = schemaElement.getAttribute("elementFormDefault");
    assertEquals("qualified", ef);
}
 
Example 25
Source Project: cxf   Source File: UTServer.java    License: Apache License 2.0 5 votes vote down vote up
protected void run() {
    Object implementor = new DoubleItImpl();
    String address = "http://localhost:" + PORT + "/DoubleItUsernameToken3";
    EndpointImpl jaxWsEndpoint = (EndpointImpl)Endpoint.publish(address, implementor);

    Map<String, Object> properties = new HashMap<>();
    properties.put("action", "UsernameToken");
    properties.put("passwordCallbackClass", "org.apache.cxf.systest.ws.common.UTPasswordCallback");
    WSS4JInInterceptor wss4jInInterceptor = new WSS4JInInterceptor(properties);

    jaxWsEndpoint.getServer().getEndpoint().getInInterceptors().add(wss4jInInterceptor);
}
 
Example 26
Source Project: cxf   Source File: ClientServerWrappedContinuationTest.java    License: Apache License 2.0 5 votes vote down vote up
protected void run() {
    SpringBusFactory bf = new SpringBusFactory();
    Bus bus = bf.createBus(SERVER_CONFIG_FILE);
    setBus(bus);
    BusFactory.setDefaultBus(bus);

    Object implementor = new HelloImplWithWrapppedContinuation();
    String address = "http://localhost:" + PORT + "/hellocontinuation";
    EndpointImpl endpointImpl = (EndpointImpl)Endpoint.publish(address, implementor);
    endpointImpl.getInInterceptors().add(new LoggingInInterceptor());
    endpointImpl.getOutInterceptors().add(new LoggingOutInterceptor());
    address = "https://localhost:" + HTTPS_PORT + "/securecontinuation";
    Endpoint.publish(address, implementor);
}
 
Example 27
Source Project: cxf   Source File: SchemaValidationClientServerTest.java    License: 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 28
Source Project: cxf   Source File: ProviderClientServerTest.java    License: 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 29
Source Project: cxf   Source File: Server.java    License: Apache License 2.0 5 votes vote down vote up
protected void run() {
    Object implementor = new AddNumberImpl();
    String address = "http://localhost:" + PORT + "/jaxws/add";
    setBus(BusFactory.getThreadDefaultBus());
    ep = new EndpointImpl(getBus(),
                          implementor,
                          null,
                          getWsdl());
    ep.publish(address);
}
 
Example 30
Source Project: cxf   Source File: Server.java    License: Apache License 2.0 5 votes vote down vote up
protected void run() {
    setBus(BusFactory.getDefaultBus());
    Object implementor = new AddNumberImpl();
    String address = "http://localhost:" + PORT + "/AddNumberImplPort";
    ep1 = new EndpointImpl(implementor);
    ep1.getFeatures().add(new WSAddressingFeature());
    ep1.publish(address);

    ep2 = new EndpointImpl(new AddNumberImplNoAddr());
    ep2.publish(address + "-noaddr");
}