Over a million developers have joined DZone.

Implementing Simple Web Services Registry Using CXF

· Integration Zone

Learn how API management supports better integration in Achieving Enterprise Agility with Microservices and API Management, brought to you in partnership with 3scale

UDDI is an enterprise-grade solution for Web Services Directory. Most of Java EE application servers are shipped with UDDI applications. I wrote about UDDI and JAXR previously: Preparing for SCDJWS Part 8: UDDI, Fixing jUDDI 0.9rc4 and Scout 1.2 bugs, and Preparing for SCDJWS Part 15: JAXR and Web Services Registries.

Today I will show you a more flyweight approach to Web Services Registry. I will use Apache CXF for it.

Bean configuration

Let's start with beans.xml configuration:
<bean id="RegistryServiceBean" class="pl.gda.pg.eti.nuntius.testcases.orders_local_business_process_services.registry.RegistryServiceImpl " />
   address="/Registry" />
:) Simple isn't it?

The implementation

Assume our registry service expects namespace and portType arguments, and returns a list of W3CEndpointReference (WS-Addressing) endpoints:
@WebService(name = "Registry", serviceName = "RegistryService")
public class RegistryServiceImpl implements ApplicationContextAware {

 private ServletTransportFactory servletTransportFactory;

 public List<W3CEndpointReference> findWebServices(
   @WebParam(name = "namespace") String namespace,
   @WebParam(name = "portType") String portType) {

  QName portTypeQName = new QName(namespace, portType);

  List<W3CEndpointReference> endpointReferences = new ArrayList<W3CEndpointReference>();

  for (ServletDestination servletDestination : servletTransportFactory
    .getDestinations()) {
   EndpointInfo endpointInfo = servletDestination.getEndpointInfo();
   if (portTypeQName.equals(endpointInfo.getInterface().getName())) {
    String address = endpointInfo.getAddress();
    W3CEndpointReference endpointReference = new W3CEndpointReferenceBuilder()

  return endpointReferences;

 @WebMethod(exclude = true)
 public void setApplicationContext(ApplicationContext applicationContext)
   throws BeansException {
  servletTransportFactory = (ServletTransportFactory) applicationContext


I think no comments are required, but if you have any questions give me a shout.


Unleash the power of your APIs with future-proof API management - Create your account and start your free trial today, brought to you in partnership with 3scale.


Published at DZone with permission of Łukasz Budnik, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}