'Multi-tenant application consuming SOAP API

We're developing a multi-tenant application which consumes an external API through SOAP. Each tenant has to purchase a subscription for the external API, and according to each tenant's requirements the API would provide different versions of the API. For example, Tenant A would get a somewhat different WSDL than Tenant B.

When implementing such scenarios in JAX-WS, we've tried to create SOAP clients using wsimport. Ideally, wsimport generates the service bean (SEI), proxy, the stubs and ObjectFactory.

However, the problem is that even though there is a WSDL for each client exposed as a web service from the external API, when we try to generate the clients using wsimport, the service beans are of same name.

We have tried the following:

  1. Merging the WSDLs to create an aggregated WSDL, and use wsimport to create a client using the aggregated WSDL. The problem with this approach, is creating such an aggregated WSDL is very difficult since there might be some conflicts with the stubs generated for each version provided to the clients from the external API.

  2. Bundle the SEI (service bean), stubs, proxy and ObjectFactory into jars for each tenant (generated using wsimport pointed to that tenant's WSDL), and load the relavant service bean at run-time. This approach looked quite convincing, until we hit a dead end when trying to invoke methods using the service bean. Since the service bean is an interface, Java Reflection API says it cannot initialize the class.

I would like to know how to resolve a scenario like the above. We might not be the first to face such a scenario so I was hoping if anyone from the community ran to such a problem as well. We're still stuck on this, so any suggession would be most welcome :) Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source