DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

Implementing Simple Web Services Registry Using CXF

Łukasz Budnik user avatar by
Łukasz Budnik
·
Jun. 07, 12 · Interview
Like (0)
Save
Tweet
Share
9.08K Views

Join the DZone community and get the full member experience.

Join For Free
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 " />
<jaxws:endpoint 
   id="RegistryService" 
   implementor="#RegistryServiceBean" 
   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()
      .address(address).build();
    endpointReferences.add(endpointReference);
   }
  }

  return endpointReferences;
 }

 @Override
 @WebMethod(exclude = true)
 public void setApplicationContext(ApplicationContext applicationContext)
   throws BeansException {
  servletTransportFactory = (ServletTransportFactory) applicationContext
    .getBean(ServletTransportFactory.class.getCanonicalName());
 }

}
Summary

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

cheers,
Łukasz
Web Service

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • OpenVPN With Radius and Multi-Factor Authentication
  • Host Hack Attempt Detection Using ELK
  • Integrate AWS Secrets Manager in Spring Boot Application
  • How To Best Use Java Records as DTOs in Spring Boot 3

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: